Encapsulate State to make it impossible to read
This was NightLightStateMachine's purpose, but it fits equally well in the actual production code.
This commit is contained in:
parent
a741938f89
commit
bd550bfcd9
4 changed files with 29 additions and 29 deletions
|
|
@ -7,7 +7,7 @@ open NightLight.Core.Models
|
|||
open NightLight.Core.Core
|
||||
|
||||
type NightLightStateMachine(now: DateTime) =
|
||||
let mutable state = { Time = now }
|
||||
let mutable state = State now
|
||||
|
||||
let transmittedCommands = new List<Message>()
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ type NightLightStateMachine(now: DateTime) =
|
|||
|
||||
let sendEvent event =
|
||||
result {
|
||||
let! newState, commands = onEventReceived state event
|
||||
let! newState, commands = state.OnEventReceived event
|
||||
state <- newState
|
||||
transmittedCommands.AddRange commands
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue