async-lifecycle v0.2.20
async-lifecycle
Generic async lifecycle actions and reducer.
Methods
composeAction
Creates an asynchronous action. The argument objects may have properties:
groupThe name of the action group, required.fireThe action function, required.args = empty.arraykeycachekeycacheValidationA predicate function that indicates whether cache content is valid. Default value always returns true.container = "data"- Astringof the property for the container in the store or afunctionwhich returns the cache containerobject, like(state, ...args) => state.foo.barcallbackBeforeCalled before callingfire.callbackSuccessCalled before dispatching theSUCCESSaction.callbackAfterCalled after dispatching theSUCCESSaction.callbackErrorCalled before dispatching theERRORaction.extratimeoutTimeout until expiry in milliseconds, default 300000 (= 5 minutes).
When multiple objects are specified:
Callback functions are merged into wrapper functions, other properties are
overwritten as in Object.assign.
loadingProgress
Determines if the given argument value corresponds to a state where data is
loading. E.g. loadingProgress("init") // true
loadingPresent
Determines if the given argument value corresponds to a state where data is
present. E.g. loadingPresent("init") // false
asyncReducer
Recalculates state from current state and an action.
Action postfixes
| Value | Description |
|---|---|
INIT | Start |
HIT | Current data already present |
QUIT | Data already loading |
SUCCESS | Data loaded successfully |
ERROR | Error |
EXIT | Finish |
INVALIDATE | Mark data as not current |
INVALIDATEALL | Mark all data as not current |
CLEAR | Delete all data |
Values for loading property
| Value | Description | Data present | Data current |
|---|---|---|---|
init | Loading | No | N/A |
success | Success | Yes | Yes |
invalid | Invalidated | Yes | No |
reinit | Reloading | Yes | No |
error | Error | No | N/A |
Build this package
yarn buildPublish this package
npm login
cp package.json dist/
cd dist
npm publish5 years ago
5 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago