{ self.person = person super.init() // Register for events self.person.registerListener(self) } deinit { // Deregister for events self.person.deregisterListener(self) } // Check if the IPAPerson has updated it's display name @objc func onEvent(event: AnyObject!) { // Verify that it's the correct kind of event guard let personEvent = event as? IPAExamplePersonEvent else { return } // Verify that the event is for an updated property guard personEvent.type == .PropertiesChanged else { return } // Check that it was the expected property that changed if personEvent.isPropertyChanged(.DisplayName) { // get the new display name } } }
predicatesAndCallbacks: [ ([ // Event verifications { event in event.type == .PropertiesChanged }, { event in event.isPropertyChanged(.DisplayName) } ], // Callback { _ in // get the new display name } ) ] ) }
{} 1-way KVO Bindings over collections (closure callbacks when elements are added/removed from the observed collection or when elements within the collection updates)