-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorder update signature to State, Action, Environment (#14)
This PR changes the order of update function arguments: - Changes update function signature from `update(State, Environment, Action)` to `update(State, Action, Environment)` - Changes Store from `Store<State, Environment, Action>` to `Store<State, Action, Environment>` Why? - This order of arguments is used by two other Elm-like libraries: [Swift Composable Architecture](https://github.com/pointfreeco/swift-composable-architecture) and [Redux-like state container](https://swiftwithmajid.com/2019/09/18/redux-like-state-container-in-swiftui/). - Context arguments like environment often seem to be passed last in Swift. E.g. [`UIViewRepresentable.Context`](https://developer.apple.com/documentation/swiftui/uiviewrepresentable/updateuiview(_:context:)) is passed last to methods in SwiftUI. - State and Action are always used, but Environment might be nil, or an empty struct. You don't always need environment. It is optional. - The order reads better in the signature, since state and action are always paired together in update function and `Update` struct.
- Loading branch information
1 parent
f21ef24
commit 546c7d0
Showing
3 changed files
with
17 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters