Skip to content

Strict Consistency

Compare
Choose a tag to compare
@andrejewski andrejewski released this 15 Jul 02:30
· 64 commits to master since this release

This patch release changes up some syntax which took some thought.

The init() and update() are now consistent with each other and removes ambiguity from their return arguments. Both functions now must return an array of [newState, optionalEffect] always and the shorthand return of newState is no longer supported. The shorthand would have been a concern if newState were an array. Also when testing an update() or init() the developer would have to know the implementation details of the init() or update() to know how to test the shorthand versus full. Without the shorthand, testing is a lot more clear.

Also, the first argument to update() is now the message, the current state is second. This decision was made because more often than not the state is derived from the message and may not even need to rely on an existing model. So when testing calling update(message) is more appealing than update(null, message). This also has implications for currying if anyone is into that.