Counter

The source code for all examples can be found on Github.

You don't write a state management library without providing a counter example.

Coverage

  • Model
  • Actions
  • Actions with Payload
  • Effects
  • Effects with Payload
0
ms
const model = 0
const actions = {
reset: () => [model],
increment: (state) => [state + 1],
decrement: (state) => [state - 1],
incrementBy: (state, increment) => [state + increment],
decrementBy: (state, decrement) => [state - decrement],
incrementIn: (state, delay) => [
state,
(actions) => setTimeout(actions.increment, delay),
],
}
Crafted with ♡ by Robin Weser