Last active
June 21, 2016 13:23
-
-
Save isaldin/598e31785ba6999db71264782ee5f62e to your computer and use it in GitHub Desktop.
AtomState template
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
extension State { | |
struct <STATE_NAME>: AtomState { | |
typealias EventType = Event | |
static var parentClass: AtomNode.Type = <#PARENT_CLASS_TYPE#> | |
static func react(optionalCurrent: <STATE_NAME>?, event: EventType) -> <STATE_NAME> { | |
guard var current = optionalCurrent else { return initial() } | |
switch event { | |
/// cases here | |
default: | |
break | |
} | |
return current | |
} | |
static func initial() -> <STATE_NAME> { | |
return <STATE_NAME>() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment