Define a module
Basic
const module = defineModule({ count: 0 })
.actions({
add: (draft) => draft.count++,
minus: (draft) => draft.count--,
})
.computed({
doubled: (state) => state.count * 2,
})
.build();
Module Factory
const addModuleBase = defineModule({ count: 0 })
const moduleA = addModuleBase.actions(...).build()
const moduleB = addModule.actions(...).build()
const withAdd = (module) => module.actions({ add: (state) => state.count++ })
const moduleC = withAdd(addModuleBase).build()Last updated