All Projects → batata-frita → redux-heat

batata-frita / redux-heat

Licence: MIT license
🔥 Redux side-effects as a function of state

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to redux-heat

SparForte
Bourne shell, template engine, scripting language mission-critical, scalable projects. Based a ISO standard proven effective for large, mission-critical projects, SparForte is designed for fast development while, at the same time, providing easier designing, maintenance and bug removal. About 120.000 lines of code.
Stars: ✭ 47 (+261.54%)
Mutual labels:  side-effects
effector-reeffect
Concurrent effects for Effector ☄️
Stars: ✭ 56 (+330.77%)
Mutual labels:  side-effects
redux-black-box
Declare side effects as black boxes in redux: an alternative to redux-thunk, redux-saga, redux-loop, ...
Stars: ✭ 21 (+61.54%)
Mutual labels:  side-effects
use-mutation
🧬 Run side-effects safely in React
Stars: ✭ 81 (+523.08%)
Mutual labels:  side-effects
bow-lite
🏹 Bow Lite is a cross-platform library for Typed Functional Programming in Swift
Stars: ✭ 27 (+107.69%)
Mutual labels:  side-effects
k-ramel
State manager for your components apps, the safe and easy way
Stars: ✭ 20 (+53.85%)
Mutual labels:  side-effects
redux-execute
Another way with thunk in redux
Stars: ✭ 18 (+38.46%)
Mutual labels:  side-effects
react-stateful-component
Functional stateful React components with sideEffect support
Stars: ✭ 19 (+46.15%)
Mutual labels:  side-effects
collateral
Map, find and isolate captured side effects
Stars: ✭ 39 (+200%)
Mutual labels:  side-effects

redux-heat 🔥

Build Status npm version

Redux side-effects as a function of state.

  • Reducers and action creators as pure functions;
  • It is not a middleware, so setup and testing are super easy;
  • Follows the same pattern as React (decide what to do based on the state and not the actions);
  • Effects are pure functions.

Install

Add it as a dependency in your project:

npm install --save redux-heat

Usage

Here is a simple example to fetch user details once the id of the user changes is the Redux store:

import subscribe from 'redux-heat'

// Define a selector to define what data to check for changes
const getUserId = state => state.userId

// Action creators
const setUserDetails = user => ({ type: 'SET_USER_DETAILS', payload: user })
const notifyUserFetchFailed = error => ({ type: 'FETCH_USER_FAILED', payload: e })

const fetchUser = userId => fetch(`/user/${userId}`)

// Describe the effect based on state changes
const fetchUserHeat = state => ({
  fn: fetchUser,
  args: [getUserId(state)],
  onValue: setUserDetails,
  onError: notifyUserFetchFailed
})

// Then subscribe the effect to the Redux store
subscribe(reduxStore, [fetchUserHeat])
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].