@zooniverse/async-states

0.0.1 • Public • Published

@zooniverse/async-states

Provides a handy immutable object for describing the state of an asynchronous request.

Available states are:

  • initialized
  • loading
  • success
  • error

Usage

Use the asyncStates object to provide the strings to describe the state of your request, rather than defining them locally. For example:

import asyncStates from '@zooniverse/async-states'

let requestState = asyncStates.initialized

function asyncRequest () {
  requestState = asyncStates.loading
  fetchSomething()
    .then(() => requestState = asyncStates.success)
    .catch(() => requestState = asyncStates.error)
}

Readme

Keywords

none

Package Sidebar

Install

npm i @zooniverse/async-states

Weekly Downloads

1

Version

0.0.1

License

Apache-2.0

Unpacked Size

3 kB

Total Files

5

Last publish

Collaborators

  • kieftrav
  • shaunanoordin
  • zooniverse-jenkins
  • goplayoutside3
  • mcbouslog