Immutable or mutable • Free-form or with a model "In information technology and computer science, a system is described as stateful if it is designed to remember preceding events or user interactions; the remembered information is called the state of the system."
Actions ◦ Dispatch • Observability ◦ Observables ◦ Publish/Subscribe "Something that happens or is regarded as happening; an occurrence, especially one of some importance." "Something that occurs in a certain place during a particular interval of time."
long running • Constrained or free "The change from one state to another is called a transition." "Movement, passage, or change from one position, state, stage, subject, concept, etc., to another; change."
jobs "Any effect of ... that is in addition to its intended effect, especially an effect that is harmful or unpleasant." "Any accompanying or consequential and usually detrimental effect"
on the developer 02. Events Actions (description) triggered by action creators, dispatched to the store 03. Transitions Reducers (pure) functions from action and state, produce a new state 04. Side effects Delegated to optional middlewares 05. Visible effects Connect state to UI through (eventually optimized) selector functions 06. Pros and cons Pros: Predictable, debuggable, extendable Cons: Boilerplate, no standard solution for side effects, immutability and modeling -> use RTK ReduxJS
Redux is explaining it in terms of API instead of how to "think in it". I underestimated the temptation to twist it into a familiar conceptual model - and that it's flexible enough to allow these contortions." - Dan Abramov
using a wrapper or a decorator. State is updated using mutable objects methods, immutability is not requested and should be avoided. Simple, scalable state management
immutability please 02. Events No special handling 03. Transitions Functions can update state directly, Actions can wrap them to optimize stuff 04. Side effects Reactions can execute side effects on state updates 05. Visible effects Reactions can update the UI on state updates (e.g. for React use the observer reaction) 06. Pros and cons Pros: Simple, scalable, reactive Cons: Some magic, UI leaks (decorators), scattered state MobX
Snapshots to interact. Views as computed state. 02. Events No special handling 03. Transitions Actions functions update the state. New Snapshots are generated. 04. Side effects Asynchronous actions modeled through JS generators. 05. Visible effects Reactions can update the UI on state updates (e.g. for React use the observer reaction) 06. Pros and cons Pros: Typed models, simple immutability, reactive Cons: More abstract and complex than MobX mobx-state-tree
(store) emits data to one or more Subscribers. 02. Events Events are values emitted by another Subject (the Dispatcher). 03. Transitions Function that emits a new state when receiving events, using RxJS operators. 04. Side effects Transition functions take care of side effects too, using RxJS operators . 05. Visible effects Subscribe to the store. Emitted values update UI. 06. Pros and cons Pros: very powerful operator library to manage transitions and side effects Cons: not really a state management library RxJS
so I can use RxJS to control my Redux state, which I can render with React!. That sounds like a lot to juggle! How does that even look?!" - James Wright
the detail context. 02. Events Sent to a state machine interpreter, using a send method. 03. Transitions Declarative state to state transitions, with explicit constraints and rules. 04. Side effects Actions, Activities, Invoked Promises and Machines are used for different purposes. 05. Visible effects Subscribe to state transitions and use context for updates. 06. Pros and cons Pros: powerful language to describe constraints and the visualizer tool Cons: steep learning curve
discipline in web development, but using them (state machines) can make application logic much more clear, communicative, and transferable. This calculator model was created 20+ years ago, and can be used directly today" - David K. Piano