Closed rtfeldman closed 7 years ago
Cool! It crossed my mind using functions instead of union types for the events, but I haven't thought deeper on the advantages or disadvantages of it. You won me at "Each event helper can have its own documentation".
LGTM
woa, hold up,I wanna review first
I've putsuggested changes on #29 @rtfeldman
Sorry @eeue56! Didn't realize you wanted to weigh in first. 😅
Having spent some time with @rogeriochaves's awesome event triggering system, I have some ideas for how to revise the API:
Current API
Proposed Change
The big change is making (lowercase) functions rather than (uppercase) union type constructors for the events.
Before:
After:
This has a few benefits.
Msg
(the uppercaseChange
) and which is the event (the lowercaseinput "cats"
- as opposed to the previousInput "cats"
).check
.Other changes include:
EventNode
toEvent
and made the oldEvent
a( String, Value )
tuple. We never treat these as anything other than function arguments that get passed around without modification, so giving them their own type doesn't seem warranted.Event
instead ofEvents
- this makesEvent.input
read nicely ("aninput
event") and makes the module name correspond to the type - theEvent
module and theEvent
type, like theMaybe
module and theMaybe
type.Events.eventResult
we can have the self-explanatoryEvent.toResult
- which takes anEvent
and returns aResult
!Events.expectEvent
toEvent.expect
- which takes anEvent
(and aMsg
) and returns anExpectation
.Thoughts?