Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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
You can’t perform that action at this time.