Reim
Github
2.0.0
2.0.0
  • Reim.js
  • Introduction
    • Motivation
    • Concepts
  • Guide
    • Store
    • setState
    • Subscribe
    • Plugin
    • Event Emitter
    • Use with React / Preact
    • Use with Vue
    • Use with Angular / Rxjs
  • Ecosystem
    • react-reim
    • reim-task
    • reim-reporter
    • reim-persist
    • Release Notes
Powered by GitBook
On this page
  • Exports
  • task
  1. Ecosystem

reim-task

import task from 'reim-task'

reim-task creates a store that updates according to state of an async function

Exports

task

task(fn: func) => Store

Creates a store from passed in async function.

The store will be updated with 3 stages

{status: 'initialized'} => {status: 'pending'} => {status: 'resolved', result } / {status: 'rejected', error}

To execute the function, you can use .exec

const aTask = task(() => {
    await fetchSomething()
})

aTask.exec() // starts fetching
Previousreact-reimNextreim-reporter

Last updated 5 years ago