0.8.3 • Published 4 years ago

sideswipeloi v0.8.3

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

State manager for js application

Usage

import { createInstance, createAction, createAsync } from "sideswipeloi"

export const increment = createAction()
export const decrement = createAction()

export const countAsync = createAsync(() => new Promise(res => setTimeout(() => res(10), 2000)))

export const iloading = createInstance(false)
  .add(countAsync.pending, () => true)
  .reset(countAsync.done)
  .reset(countAsync.fail)

export const icount = createInstance(0)
  .add(increment, state => state + 1)
  .add(decrement, state => state - 1)
  .add(countAsync.done, (_, value) => value)

icount.subscribe(console.log)
iloading.subscribe(console.log)

increment()
// {state: 1, params: undefined}

increment(1)
// {state: 2, params: 1}

decrement()
// {state: 1, params: undefined}
;(async () => {
  await countAsync()
  // {state: 10, params: 10}
})()
0.8.3

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago