Reclare is a Lightweight JavaScript Library to Manage State and Logic together

July 24, 2018
Node.js

Reclare

Reclare is a lightweight library to manage the application state alongside business logic. It is inspired by Redux and the Elm architecture.

What it does

  • Manage state and logic together
  • Predictable, immutable state management
  • Handle requests / side effects
  • Built-in way to modularise your code
  • For all frameworks (offical middleware for React)
  • Simple to create and use custom middlewares
  • Easy to install, minimal configuration
  • Easy-to-grasp concepts

Author example (from npmjs.com):

{
on: 'increment',
reducer: ({ state }) => ({ ...state, counter: state.counter + 1 })
reaction: ({ state }) => console.log(`Incremented to ${state.counter}`)
},
{
on: 'decrement',
situation: ({ state }) => state.counter > 0,
reducer: ({ state }) => ({ ...state, counter: state.counter - 1 }),
reaction: ({ state }) => console.log(`Decremented to ${state.counter}`)
},
{
on: 'decrement',
situation: ({ state }) => state.counter <= 0,
reaction: () => alert('Counter already at zero')
}

<Button value="+" onClick={() => broadcast('increment')} />
<Button value="-" onClick={() => broadcast('decrement')} />

Creator: Oguz Gelal
License: MIT.

Where to Find Reclare

project/docs website: https://docs.reclare.io

On npm: https://www.npmjs.com/package/reclare

On github: https://github.com/reclarejs/reclare

Author article: “The Logic in State Management

Recommended Installation:

yarn add reclare
​ or npm install reclare –save

Then add the React middleware (recommended for React projects):

yarn add react-reclare
​ or npm install react-reclare –save