Installations
npm install reflux-promise
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
4.2.2
NPM Version
2.14.7
Score
84.5
Supply Chain
98.9
Quality
79
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
reflux
Download Statistics
Total Downloads
1,750,716
Last Day
99
Last Week
3,694
Last Month
32,629
Last Year
560,804
GitHub Statistics
22 Stars
27 Commits
23 Forks
4 Watching
1 Branches
8 Contributors
Package Meta Information
Latest Version
1.0.4
Package Id
reflux-promise@1.0.4
Size
5.96 kB
NPM Version
2.14.7
Node Version
4.2.2
Total Downloads
Cumulative downloads
Total Downloads
1,750,716
Last day
-88.6%
99
Compared to previous day
Last week
-48.8%
3,694
Compared to previous week
Last month
-35%
32,629
Compared to previous month
Last year
197.7%
560,804
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
Dev Dependencies
10
reflux-promise
Plugin for reflux-core to use Promises.
Here are the API docs for reflux-promise.
Installation
You can currently install the package as an npm package.
NPM
The following command installs reflux-promise
as an npm package:
npm install reflux-promise
Usage
To install promise functionality do the following in your application's bootstrapper:
1import Reflux from "reflux"; 2import RefluxPromise from "reflux-promise"; 3 4// Uses the user agent's Promise implementation 5Reflux.use(RefluxPromise(window.Promise)); 6 7// Uses Q 8import Q from "q"; 9Reflux.use(RefluxPromise(Q.Promise)); 10 11// Uses bluebird 12import bluebird from "bluebird"; 13Reflux.use(RefluxPromise(bluebird))
Extensions to Asynchronous actions
reflux-promise
extends asynchronous actions, i.e.:
1// this creates 'load', 'load.completed' and 'load.failed' 2var { load } = Reflux.createActions({ 3 "load": {children: ["completed","failed"]} 4});
A couple of helper methods are available to trigger the completed
and failed
child actions:
-
promise
-
listenAndPromise
The following are all equivalent:
1// Using load above with a promise here called "apiPromise" 2load.listen( function(arguments) { 3 apiPromise(arguments) 4 .then(load.completed) 5 .catch(load.failed); 6}); 7 8// Can be shortened down to use `promise` like below 9load.listen( function(arguments) { 10 load.promise( apiPromise(arguments) ); 11}); 12 13// Furthermore with `listenAndPromise` 14load.listenAndPromise( apiPromise );
Asynchronous actions as Promises
PublisherMethods#triggerAsync
is modified so that asynchronous actions can be used as promises. The following example is for server-side rendering when you must await the successful (or failed) completion of an action before rendering. Suppose you had an action, makeGetRequest
, and a store, RequestStore
, to make an API request:
1// Create async action with `completed` & `failed` children 2var makeGetRequest = Reflux.createAction({ asyncResult: true }); 3 4var RequestStore = Reflux.createStore({ 5 init: function() { 6 this.listenTo(makeRequest, 'onMakeRequest'); 7 }, 8 9 onMakeGetRequest: function(url) { 10 // Assume `request` is some HTTP library (e.g. superagent) 11 request.get(url, function(err, res) { 12 if (err) { 13 return makeGetRequest.failed(err); 14 } 15 makeGetRequest.completed(body); 16 }) 17 } 18});
You could use promises to make the request and either render or serve an error:
1makeGetRequest.triggerAsync('/api/something').then(function(body) { 2 // Render the response body 3}).catch(function(err) { 4 // Handle the API error object 5});
Colophon
List of contributors is available on Github.
This project is licensed under BSD 3-Clause License. Copyright (c) 2014, Mikael Brassman.
For more information about the license for this particular project read the LICENSE.md file.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: BSD 3-Clause "New" or "Revised" License: LICENSE.md:0
Reason
Found 8/25 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 10 are checked with a SAST tool
Score
3.4
/10
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More