fetch-observable
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "fetch-observable", | ||
"description": "Observable-based Fetch API", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "BSD-3-Clause", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -1,10 +0,10 @@ | ||
# fetchObservable | ||
# fetchObservable() | ||
Observable-based [Fetch API](https://github.com/whatwg/fetch) that automatically refreshes data. | ||
Observable-based [Fetch API](https://github.com/whatwg/fetch) that automatically refreshes data and notifies subscribers. | ||
## Features | ||
- API similar to the standard Fetch API. | ||
- Uses the standard Fetch API. | ||
- Uses Observable syntax from [ES Observable proposal](https://github.com/zenparsing/es-observable). | ||
- Runs in Node and browsers. | ||
- Runs in Node and browsers. (BYO Promises though) | ||
@@ -14,3 +14,2 @@ ## Installation | ||
```bash | ||
# For web or Node: | ||
npm install --save fetch-observable | ||
@@ -24,9 +23,11 @@ ``` | ||
// Creates a single fetchObservable for one or multiple URLs. | ||
// Creates a single observable for one or multiple URLs. | ||
const liveFeed = fetchObservable( | ||
"http://example.org/live-feed.json", | ||
{refreshDelay (iteration) { return iteration * 1000; }} | ||
{ | ||
refreshDelay: (iteration) => iteration * 1000 // <-- Callback or just integer ms. | ||
} | ||
); | ||
// Subscribe-syntax like ES Observables. | ||
// Subscribe-syntax of ES Observables. | ||
const subscription1 = liveFeed.subscribe({ | ||
@@ -48,2 +49,5 @@ next (response) { | ||
subscription1.resubscribe(); // <-- Observable resumes on 1 subscription. | ||
liveFeed.pause(); // <-- Observable can be paused manually. | ||
liveFeed.resume(); | ||
```` | ||
@@ -50,0 +54,0 @@ |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @copyright © 2015, Rick Wong. All rights reserved. | ||
*/ | ||
import __fetch from "isomorphic-fetch"; | ||
@@ -2,0 +5,0 @@ import PausableObservable from "lib/PausableObservable"; |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @copyright © 2015, Rick Wong. All rights reserved. | ||
*/ | ||
import {Observable} from "lib/Observable"; | ||
@@ -2,0 +5,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64670
10
1377
60
4