Skip to content

Instantly share code, notes, and snippets.

@cipolleschi
Created April 26, 2020 13:45
Show Gist options
  • Select an option

  • Save cipolleschi/cbe4f65e61766a43b5f44219cce72261 to your computer and use it in GitHub Desktop.

Select an option

Save cipolleschi/cbe4f65e61766a43b5f44219cce72261 to your computer and use it in GitHub Desktop.
var observers: [String: <#ObserverType#>] = [:]
func add(observer: <#ObserverType#>) -> String {
let uuid = UUID().uuidString
self.observers[uuid] = observer
return uuid
}
func remove(observer uuid: String) {
self.observers.remove(at: uuid)
}
func notifyObservers(<#paramList#>>) {
self.observers.forEach { $0.<#notifyMethod#> }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment