Package Exports
- pull-streamdata.io
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pull-streamdata.io) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
pull-streamdata.io
streamdata.io server-sent events as a pull-stream source
Creates a pull-stream source from streamdata.io sever-sent events (SSE) in Node.js and the browser
Usage
var streamdata = require('pull-streamdata.io')
var pull = require('pull-stream')
var URL = 'https://www.reddit.com/r/random.json?obey_over18=true'
var appToken = 'ODRlZDNmYmUtMDAxZC00NWJmLTgwMzQtNTkzMWJiYjFhYjVj'
var SSE = streamdata(URL, appToken)
// pull from streamdata.io 4 times and then closes the SSE
pull(
SSE,
pull.take(4),
pull.log()
)
outputs
{kind: "Listing", data: {…}}
{kind: "Listing", data: {…}}
{kind: "Listing", data: {…}}
{kind: "Listing", data: {…}}
streamdataio.min.js:1 Closing the SSE Stream.
API
var streamdata = require('pull-streamdata.io')
streamdata(url, appToken, headers, privateKey)
- url: (String) The rest endpoint you set https://streamdata.io to poll for changes.
- appToken: (String) Your auth key from https://streamdata.io
- headers: (Optional) (Array) Additional headers for the SSE
- privateKey (Optional) (String): Your private auth key from streamdata.io if you chose to generate one
Install
With npm installed, run
$ npm install pull-streamdata.io