0.2.20 • Published 4 years ago

async-lifecycle v0.2.20

Weekly downloads
6
License
MIT
Repository
-
Last release
4 years ago

async-lifecycle

Generic async lifecycle actions and reducer.

Methods

composeAction

Creates an asynchronous action. The argument objects may have properties:

  • group The name of the action group, required.
  • fire The action function, required.
  • args = empty.array
  • key
  • cachekey
  • cacheValidation A predicate function that indicates whether cache content is valid. Default value always returns true.
  • container = "data" - A string of the property for the container in the store or a function which returns the cache container object, like (state, ...args) => state.foo.bar
  • callbackBefore Called before calling fire.
  • callbackSuccess Called before dispatching the SUCCESS action.
  • callbackAfter Called after dispatching the SUCCESS action.
  • callbackError Called before dispatching the ERROR action.
  • extra
  • timeout Timeout 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

ValueDescription
INITStart
HITCurrent data already present
QUITData already loading
SUCCESSData loaded successfully
ERRORError
EXITFinish
INVALIDATEMark data as not current
INVALIDATEALLMark all data as not current
CLEARDelete all data

Values for loading property

ValueDescriptionData presentData current
initLoadingNoN/A
successSuccessYesYes
invalidInvalidatedYesNo
reinitReloadingYesNo
errorErrorNoN/A

Build this package

yarn build

Publish this package

npm login
cp package.json dist/
cd dist
npm publish
0.2.20

4 years ago

0.2.19

4 years ago

0.2.18

5 years ago

0.2.17

5 years ago

0.2.16

6 years ago

0.2.15

6 years ago

0.2.13

6 years ago

0.2.12

6 years ago

0.2.11

6 years ago

0.2.11-7

6 years ago

0.2.11-6

6 years ago

0.2.11-5

6 years ago

0.2.11-4

6 years ago

0.2.11-3

6 years ago

0.2.11-2

6 years ago

0.2.11-1

6 years ago

0.2.11-0

6 years ago

0.2.10

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago