Wondering what‚Äôs next for npm?Check out our public roadmap! ¬Ľ

    @async-resource/core
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.0¬†‚Äʬ†Public¬†‚Äʬ†Published

    @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')

    Install

    npm i @async-resource/core

    DownloadsWeekly Downloads

    2

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    73.6 kB

    Total Files

    28

    Last publish

    Collaborators

    • avatar