🛡️
Type Safety
Use reliable and expressive typescript constructs to build your app state
Expressive, concise and robust state management for typescript ecosystem
const AppLoadingState = defineFlow(
m,
"AppLoadingState",
() => [m.states.initial({ loadingStarted: Date.now() }), m.cmds.loadLocalStorage()],
{
initial: {
local_storage_loaded: (msg, model) => {
return [
m.states.waiting_initialize({
...model,
localSave: msg.localSave
}),
m.cmds.initialize()
];
}
},
waiting_initialize: {
initialized: (msg, model) => {
return [
m.states.waiting_config({
...model,
initialize_data: msg.data
}),
m.cmds.loadConfig(msg.data.configUrl)
];
}
},
waiting_config: {
config_loaded: (msg, model) => {
return [
m.states.loaded({
...model,
config: msg.config,
loadingFinished: msg.now
}),
];
}
},
loaded: {}
}
)