- Notifications
You must be signed in to change notification settings - Fork5
Driver for HTTP requests through JSONP
License
cyclejs/jsonp
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A Driver for making HTTP requests through the JSONP hack, based on thejsonp package. This package is small, hacky (as JSONP is too), and untested. Whenever possible, use proper server and client CORS solution with the HTTP Driver.
npm install @cycle/jsonpfunctionmain(responses){// This API endpoint returns a JSON responseconstHELLO_URL='http://localhost:8080/hello';letrequest$=Rx.Observable.just(HELLO_URL);letvtree$=responses.JSONP.filter(res$=>res$.request===HELLO_URL).mergeAll().startWith({text:'Loading...'}).map(json=>h('div.container',[h('h1',json.text)]));return{DOM:vtree$,JSONP:request$};}Cycle.run(main,{DOM:makeDOMDriver('.js-container'),JSONP:makeJSONPDriver()})
JSONP Driver factory.
This is a function which, when called, returns a JSONP Driver for Cycle.jsapps. The driver is also a function, and it takes a stream of requests(URL strings) as input, and generates a metastream of responses.
Requests. The stream of requests should emit strings as the URL of theremote resource over HTTP.
Responses. A metastream is a stream of streams. The response metastreamemits streams of responses. These streams of responses have arequestfield attached to them (to the stream object itself) indicating whichrequest (from the driver input) generated this response stream. Theresponse streams themselves emit the response object received through thenpmjsonp package.
(Function) the JSONP Driver function
About
Driver for HTTP requests through JSONP
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.