@async-resource/core

High-Level Resource Manager for Flux Architecure

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@async-resource/core
Minified + gzip package size for @async-resource/core in KB

Readme

@async-resource/core

Installation

npm install --save @async-resource/core

Usage

import {
  registerResource,
  subscribe,
} from '@async-resource/core'

// -> Register resource
registerResource('user', {
  source: () => axios.get('/rest/user-info'),
  cache: { TTL: 24 * 60 * 60 * 1000 } // caches for a day
})

// -> listen for resource change
subscribe('user', resource => {
  // readonly cache: boolean
  // readonly loading: boolean
  // readonly loaded: boolean
  // readonly error: string | null
  // readonly data: any
})

// ...

// -> call resource
resources.consume('user')

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.