All Projects → artalar → Reatom

artalar / Reatom

Licence: mit
State manager with a focus of all needs

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Reatom

RxReduxK
Micro-framework for Redux implemented in Kotlin
Stars: ✭ 65 (-88.54%)
Mutual labels:  flux, state-management, state, store
okito
Your best flutter coding friend. All in one; state management, navigation management(with dynamic routing), local storage, localization, dependency injection, cool extensions with best usages and with the support of best utilities!
Stars: ✭ 37 (-93.47%)
Mutual labels:  state-management, state, store
vue-reactive-store
A VueX alternative : declarative + reactive + centralized way to structure your data store. Inspired by VueX and Vue.js . Compatible with vue-devtools.
Stars: ✭ 27 (-95.24%)
Mutual labels:  state-management, state, store
Effector
The state manager ☄️
Stars: ✭ 3,572 (+529.98%)
Mutual labels:  reactive, state-management, state
Store
A beautifully-simple framework-agnostic modern state management library.
Stars: ✭ 204 (-64.02%)
Mutual labels:  reactive, state, store
mafuba
Simple state container for react apps.
Stars: ✭ 20 (-96.47%)
Mutual labels:  flux, state, store
agile
🌌 Global State and Logic Library for JavaScript/Typescript applications
Stars: ✭ 90 (-84.13%)
Mutual labels:  reactive, state-management, state
Freezer
A tree data structure that emits events on updates, even if the modification is triggered by one of the leaves, making it easier to think in a reactive way.
Stars: ✭ 1,268 (+123.63%)
Mutual labels:  flux, state-management, store
vue
Vue integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores
Stars: ✭ 25 (-95.59%)
Mutual labels:  state-management, state, store
teaful
🍵 Tiny, easy and powerful React state management
Stars: ✭ 638 (+12.52%)
Mutual labels:  state-management, state, store
vuex-but-for-react
A state management library for React, heavily inspired by vuex
Stars: ✭ 96 (-83.07%)
Mutual labels:  flux, state-management, state
Mobx Rest
REST conventions for Mobx
Stars: ✭ 164 (-71.08%)
Mutual labels:  reactive, state-management, state
Swiftdux
Predictable state management for SwiftUI applications.
Stars: ✭ 130 (-77.07%)
Mutual labels:  reactive, state-management, state
temperjs
State management for React, made simple.
Stars: ✭ 15 (-97.35%)
Mutual labels:  flux, state-management, state
Flooks
🍸 A state manager for React Hooks
Stars: ✭ 201 (-64.55%)
Mutual labels:  flux, state, store
deep-state-observer
State library for high performance applications.
Stars: ✭ 25 (-95.59%)
Mutual labels:  reactive, state, store
Vue State Store
📮 VSS (Vue State Store) - Vue State Management (with Publish & Subscribe pattern)
Stars: ✭ 128 (-77.43%)
Mutual labels:  state-management, state, store
Little State Machine
📠 React custom hook for persist state management
Stars: ✭ 654 (+15.34%)
Mutual labels:  flux, state-management, state
mutable
State containers with dirty checking and more
Stars: ✭ 32 (-94.36%)
Mutual labels:  flux, state-management, state
Westore
更好的小程序项目架构
Stars: ✭ 3,897 (+587.3%)
Mutual labels:  state-management, state, store

reatom logo

npm npm type definitions npm bundle size GitHub



Reatom is declarative and reactive state manager, designed for both simple and complex applications.

Goals and features

  • 🐣 simple abstraction and friendly DX: minimum boilerplate and tiny API
  • ❗️ static typed: best type inferences
  • performance: performant updates for partial state changes
  • 🗜 small size: 2 KB gzipped
  • 📦 modular: reusable instances (SSR)
  • 🍴 lazy: solution for code splitting out of the box
  • 🔌 framework-agnostic: independent and self-sufficient
  • 🧪 testing: simple mocking
  • 🛠 debugging: immutable data, devtools (redux ecosystem support by adapter)
  • 🔮 deterministic: declarative and predictable specification of state shape and its mutations
  • 👴 ES5 support: by polyfills
  • 🧯 reliable: predictable flow exceptions
  • synchronous glitch free: resolve diamond problem
  • simple integration with other libraries (Observable, redux ecosystem, etc)
  • awkward to write bad code
  • easy to write good code

Description

Reatom is a blend of the one-way data flow (by flux and global store) and decentralized atoms for deterministic and flexible description of state and its changes.

Inspired by redux, kefir, effector

Data flow diagram:

reatom data flow

Installation

npm i @reatom/core

or

yarn add @reatom/core

Usage

Open in CodeSandbox

import { declareAction, declareAtom, map, createStore } from '@reatom/core'

/** Actions */
const increment = declareAction()
const add = declareAction()

/** Atoms */
const countAtom = declareAtom(1, on => [
  on(increment, state => state + 1),
  on(add, (state, payload) => state + payload),
])
const isOddAtom = map(countAtom, count => Boolean(count % 2))

/** Store */
const store = createStore()

store.subscribe(countAtom, count => console.log('`count` state: ', count))
store.subscribe(isOddAtom, isOdd => console.log('`isOdd` state: ', isOdd))
store.subscribe(add, payload => console.log('`add` payload: ', payload))

store.dispatch(increment())
// `count` state: 2
// `isOdd` state: false

store.dispatch(add(2))
// `count` state: 4
// `add` payload: 2
// here `isOdd` subscriber will not be called because its value is not changed

Packages

Package Version Size
@reatom/core npm npm bundle size
@reatom/react npm npm bundle size
@reatom/angular npm npm bundle size
@reatom/observable npm npm bundle size
@reatom/babel-plugin npm -
@reatom/debug npm npm bundle size

Motivation

Why another state manager? The reason is dissatisfaction with existing solutions that do not cover our requirements. We strive to create a lightweight state manager that combines the best solutions proven over the years and personal experience.

NOTE. Please do not consider these arguments as a way to dissuade you from using these libraries. These are very interesting projects and they deserve your attention. This list only shows the motivation for creating Reatom.

Redux

link to repository

  • Selectors are not inspectable (lacking in devtools).
  • Difficult static type inference (every selector must know the full path to parent state).
  • Hard for modular architecture (every selector must know about parent state).
  • Separation of interfaces (reducers and selectors) complicates the prototyping of separated domains.
  • Selectors - manual API for state. They must be manually described and memoized.
  • Selectors are executed after state change at subscriptions - error in selector will throw an error. Also it is not possible (possible, but really hard) to restore the previous valid state.
  • Classic reducer API and [static] type descriptions have a lot of boilerplate.
  • Selectors are "runtime" oriented; if a "feature" uses any part of the state (by selector) and later you remove this part, you will get an error only when mounting your "feature" at runtime (if you do not have static typing). The single solution is to connect all features statically by imports.
  • Middleware is a confusing pattern that can unexpectedly modify the behavior of the store. For example, actions for redux-thunk do not log.

    Some problems can be solved by various fabric functions and third party libriaries. This makes it diffcuilt to reuse solutions across multiple projects.

Effector

link to repository

  • Effector is about atomic stores — it uses stateful approach and has a problems as a any Producers:
    • probable memory leaks, because an store existents controlled not by a consumers (subscribers), but by a data sources, that is a more common.

      if you have a source A and derived source B and C, even if only B has a subscribers and need to application workflow, C still be receiving an updates and calculate it, even if nobody need it.

    • difficult [store] instance reusability.

      It can be solved, but it is better to solve it by design of a library architecture and API

  • Asynchronous and probably cyclic dependencies specification - it less predictable than describe all dependencies with instance creation.
  • The size (Reatom is 3 times lighter).
  • Throw in reducer does not cancel the computations in other reducers

MobX

link to repository

Community

Follow us on Twitter @reatomjs

Telegram

Mass media


Next:

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Arutyunyan Artyom

💻 🤔 ⚠️ 🚇 👀 💡 📖

Sergey Belozyorcev

💻 🤔 ⚠️ 🚇 👀 🎨 💡 📖

Alexey

💻 🤔 🚇 ⚠️ 📦 🔌 🔧

Anton

📖

Taymuraz Kaytmazov

📖

Ilya

📖

Shmavon Gazanchyan

📖 🚇

Ilya Zaitsev

📖

Ivakhnenko Dmitry

💻

Paul Ekshmidt

🚇

Лубяной Евгений

💻

Nikita Stenin

💻 🚇

Alexander Zenov

💻

ivan-nemtinov

💻

Viktor Pasynok

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

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].