Gathering detailed insights and metrics for flux-standard-action
Gathering detailed insights and metrics for flux-standard-action
Gathering detailed insights and metrics for flux-standard-action
Gathering detailed insights and metrics for flux-standard-action
A human-friendly standard for Flux action objects.
npm install flux-standard-action
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
4,749 Stars
104 Commits
142 Forks
50 Watching
4 Branches
19 Contributors
Updated on 24 Nov 2024
Minified
Minified + Gzipped
JavaScript (61.64%)
TypeScript (38.36%)
Cumulative downloads
Total Downloads
Last day
-11.8%
19,959
Compared to previous day
Last week
13.3%
122,422
Compared to previous week
Last month
15.8%
451,994
Compared to previous month
Last year
-8.6%
5,939,666
Compared to previous year
2
20
A human-friendly standard for Flux action objects. Feedback welcome.
It's much easier to work with Flux actions if we can make certain assumptions about their shape. For example, essentially all Flux actions have an identifier field, such as type
, actionType
, or actionId
. Many Flux implementations also include a way for actions to indicate success or failure, especially as the result of a data-fetching operation. Defining a minimal, common standard for these patterns enables the creation of useful tools and abstractions.
Flux actions can be thought of as an asynchronous sequence of values. It is important for asynchronous sequences to deal with errors. Currently, many Flux implementations don't do this, and instead define separate action types like LOAD_SUCCESS
and LOAD_FAILURE
. This is less than ideal, because it overloads two separate concerns: disambiguating actions of a certain type from the "global" action sequence, and indicating whether or not an action represents an error. FSA treats errors as a first class concept.
A basic Flux Standard Action:
1{ 2 type: 'ADD_TODO', 3 payload: { 4 text: 'Do something.' 5 } 6}
An FSA that represents an error, analogous to a rejected Promise:
1{ 2 type: 'ADD_TODO', 3 payload: new Error(), 4 error: true 5}
An action MUST
type
property.An action MAY
error
property.payload
property.meta
property.An action MUST NOT include properties other than type
, payload
, error
, and meta
.
type
The type
of an action identifies to the consumer the nature of the action that has occurred. type
is a string constant. If two types are the same, they MUST be strictly equivalent (using ===
).
payload
The optional payload
property MAY be any type of value. It represents the payload of the action. Any information about the action that is not the type
or status of the action should be part of the payload
field.
By convention, if error
is true
, the payload
SHOULD be an error object. This is akin to rejecting a promise with an error object.
error
The optional error
property MAY be set to true
if the action represents an error.
An action whose error
is true is analogous to a rejected Promise. By convention, the payload
SHOULD be an error object.
If error
has any other value besides true
, including undefined
and null
, the action MUST NOT be interpreted as an error.
meta
The optional meta
property MAY be any type of value. It is intended for any extra information that is not part of the payload.
The module flux-standard-action
is available on npm. It exports a few utility functions.
isFSA(action)
1import { isFSA } from 'flux-standard-action';
Returns true if action
is FSA compliant.
isError(action)
1import { isError } from 'flux-standard-action';
Returns true if action
represents an error.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 7/29 approved changesets -- score normalized to 2
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
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
57 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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