Last active
May 16, 2016 08:54
-
-
Save amberstar/c851430c7d810642e2c860c6eddfda5e to your computer and use it in GitHub Desktop.
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
// events | |
public struct ComponentEvents { | |
public var appEvent = Port<(component: Component, event: EventType)>() | |
} | |
subcomponent.events.appEvent.subscribe { component, event in | |
self.applicationEvent(component, event: event) | |
} | |
func applicationEvent(component: Component, event: Event) { | |
switch event.type { | |
case .HandledEvent(let isOn): | |
state.setState = isOn | |
case .HandledEvent2 : | |
// handle event 2 | |
default: | |
// send unhandled event up to parent component | |
event.send(component: component, event: event.type) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment