Readonly
decideReadonly
evolveReadonly
initialCombine multiple Deciders into one Decider - Monoid
State/S is combined via intersection / (S & S2)
. It only makes sense if S ans S2 are objects, not primitives.
Check alternative method combineViaTuples
Intersections provide more flexibility and can handle more complex scenarios, while tuples are more straightforward and may be more suitable for simple cases.
Flexibility: If you anticipate needing to access individual components of the combined state separately, using tuples might be more appropriate, as it allows you to maintain separate types for each component. However, if you primarily need to treat the combined state as a single entity with all properties accessible at once, intersections might be more suitable.
Readability: Consider which approach makes your code more readable and understandable to other developers who may be working with your codebase. Choose the approach that best communicates your intentions and the structure of your data.
Compatibility: Consider the compatibility of your chosen approach with other libraries, frameworks, or tools you're using in your TypeScript project. Some libraries or tools might work better with one approach over the other.
Combine multiple Deciders into one Decider - Monoid
State/S is combined via tuples / [S, S2]
. Check alternative method combine
Tuples are more straightforward and may be more suitable for simple cases, while intersections provide more flexibility and can handle more complex scenarios.
Flexibility: If you anticipate needing to access individual components of the combined state separately, using tuples might be more appropriate, as it allows you to maintain separate types for each component. However, if you primarily need to treat the combined state as a single entity with all properties accessible at once, intersections might be more suitable.
Readability: Consider which approach makes your code more readable and understandable to other developers who may be working with your codebase. Choose the approach that best communicates your intentions and the structure of your data.
Compatibility: Consider the compatibility of your chosen approach with other libraries, frameworks, or tools you're using in your TypeScript project. Some libraries or tools might work better with one approach over the other.
Generated using TypeDoc
Decider
is a datatype that represents the main decision-making algorithm. It has three generic parametersC
,S
,E
, representing the type of the values thatDecider
may contain or use.Decider
can be specialized for any typeC
orS
orE
because these types does not affect its behavior.Decider
behaves the same forC
=Int
orC
=YourCustomType
, for example.Decider
is a pure domain component.Param: decide
A function/lambda that takes command of type
C
and input state of typeS
as parameters, and returns/emits the list of output eventsE[]
>Param: evolve
A function/lambda that takes input state of type
S
and input event of typeE
as parameters, and returns the output/new stateS
Param: initialState
A starting point / An initial state of type
S
Author
Иван Дугалић / Ivan Dugalic /
Idugalic
Example