Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Driver for HTTP requests through JSONP

License

NotificationsYou must be signed in to change notification settings

cyclejs/jsonp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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/jsonp

Usage

functionmain(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()})

API

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.

Returns:

(Function) the JSONP Driver function

About

Driver for HTTP requests through JSONP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp