Gathering detailed insights and metrics for reflux-promise
Gathering detailed insights and metrics for reflux-promise
Gathering detailed insights and metrics for reflux-promise
Gathering detailed insights and metrics for reflux-promise
npm install reflux-promise
Typescript
Module System
Node Version
NPM Version
84.5
Supply Chain
98.9
Quality
79
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
1,750,716
Last Day
99
Last Week
3,694
Last Month
32,629
Last Year
560,804
22 Stars
27 Commits
23 Forks
4 Watching
1 Branches
8 Contributors
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
Cumulative downloads
Total Downloads
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
1
10
Plugin for reflux-core to use Promises.
Here are the API docs for reflux-promise.
You can currently install the package as an npm package.
The following command installs reflux-promise
as an npm package:
npm install reflux-promise
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))
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 );
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});
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
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
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
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