Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

RobertKoval/Observable-Swift-Protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Observable-Swift-Protocol

Mainly used in situation when you need to hold many delegates (without strong references) and call some method for each.

protocol PlayerObserver: AnyObject  {
	func someMethod()
}

class Player: NSObject, Observable, AVAudioPlayerDelegate {
	typealias ObserverType = PlayerObserver // protocol

	var observers: [() -> PlayerObserver?] = []

	func somethigChanged() {
		send { $0.someMethod() }  // call someMethot on all available observers
	}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages