It is not product-ready. You should carefully consider using this package in your production environment.
Beat Station - State management with state machine
This project is my toy project to simplify the state management flows in Flutter and dart. Whole functionalities are heavily inspired by xstate.js.
I highly recommend reading the docs of xstate.js.
Go to the Beatly Book, 한국어 문서 for more information.
Roadmap
beat will be gradually improved and polished in the future. I have a kind of roadmap.
State management for Dart-only applications
You can use beat as a Dart's state management system.
State management for Flutter applications
beat provides a set of widgets that will increase your productivity
when building your flutter application. beat also provides
inspectors for debugging your state machine.
GUI for state machines
Low-coding GUI application for your flutter's state machine.
beat market place
You can share and sell your wonderful state machine.
Real-time collaboration of state machines
Your team can collaborate online in real-time.
Others
I aim to make beat to be a framework for flutter applications.
There will be another enhancement in the future including
easier network requests, form validation, render/computation separation,
and others. I might implement some kind of full-stack dart framework in the future.
Features compatible with xstate.js
A roadmap is as follows, but the order does not matter.
xSupport simple state transition without contextxListen to state and context changesxaddListeners/removeListenersand variations are for statexaddContextListeners/removeContextListenersis for contextxstateStreamforBeatState,enumStreamfor your enum state, andcontextStreamfor your data.
xMap statesxExecute callback on state changexSupport resetxSupport contextxInitialize with contextxGet current contextxassign new context
xSupport transition with an argumentSupport nested(compound, hierarchical) statexDefine compound statexUsingsendxUsing verbose styled transition via{compoundStateName}CompoundfieldxMulti-level (deeply nested) compound stateCustom initialization on parent state creationxGet a current state of nested state usingcurrentStatecurrentState.of(EnumType)returns the current state of the nested state
xReset on parent state enter/exitxReset on parent state reset
xSupport state change historyxSupport any state transitionxBeatStation with commonBeatoption
xSupportstate.matchesas ais{State}xSupportsend()styled transitionstation.sendis supported
Support initial context defined in the station annotationSupport actions (fire-and-forget)xcallback actionxassign actionxcallback action with variable length of argumentsxchoose actionforwardTo actionlog actionpure actionraise actionrespond actionsend action
Support invoking servicesxasync function (or Future)xonDone/onError actionsonDone/onError transitionsxto current stationto nested station
callbackobservablesother beat stationmultiple services
Support instance optionsxinitial state, contextdynamically defined actions, services, delays, guards
xSupport eventless(always) transitionxSupport delayed transitionxDelay on eventless transitionxDelay onsendor$event()
SupportentryandexitactionsSupport conditional (guarded) transitionSupport custom functionsSupportinstate condition
Support internal transitionSupport external transitionSupport Forbidden transitionSupport multiple targetsSupport multiple eventsSupport actorsxSupportstate.nextEventsSupportstate.changedxSupportstate.doneSupportstate.meta,state.tagsSupportstate.canSupport history JSON to persisttoString()is currently supported
Support parallel stateDefine parallel stateSupport multiple targets event
SeparateinterpreterandstationSupport puretransition()
Event history with event sourcingManually execute actions,execute(state)referencewaitFor(state, timeout)method referenceSupport scxmlSupport bootstrappingSupport CLI/GUI toolsxstate.js compatible beat station
Additionals for flutter
Support beat-station-friendly flutter widgetsInspect state, history, event history, next events, etc., from devtools widget inspectorSupportremix.run's conceptloaderaction(side effect)ErrorBoundary/CatchBoundary
Support navigation
Usage
Libraries
- beat
- Beatly.dev's state management library.