RVS_GeneralObserverProtocol
public protocol RVS_GeneralObserverProtocol
This protocol allows any entity to become an observer. The only required component is a UUID.
-
This is a unique ID for this Observer.
If you are an observer, then you MUST supply a unique ID that remains constant throughout the lifetime of the instance.
It must be declared as a stored property, and initialized with UUID(). After that, leave it alone.
It should look like this, in your implementation:
let uuid = UUID()
Declaration
Swift
var uuid: UUID { get }
-
amISubscribed(_:
Default implementation) This will tell us whether or not we are subscribed to the given observable.
Default Implementation
The default simply asks the observable.
Declaration
Swift
func amISubscribed(_: RVS_GeneralObservableProtocol) -> Bool
-
unsubscribeFrom(_:
Default implementation) This is how an observer unsubscribes itself from an Observable.
Default Implementation
Default simply unsubscribes itself, using the Observable’s method.
Declaration
Swift
@discardableResult func unsubscribeFrom(_: RVS_GeneralObservableProtocol) -> Bool
Return Value
True, if the unsubscription was successful.
-
subscribeTo(_:
Default implementation) Subscribes us to an Observable.
Default Implementation
Default asks the Observable to sign us up.
Declaration
Swift
@discardableResult func subscribeTo(_ inObservableInstance: RVS_GeneralObservableProtocol) -> RVS_GeneralObserverProtocol?
Return Value
Our instance, or nil, if the subscription failed. Can be ignored.
-
subscribedTo(_:
Default implementation) This is called after being subscribed to an Observable.
This is called after the Observable’s
observer(_:, didSubscribe:)
method was called.In the default implementation, this is called in the subscription execution context, so that will be the thread used for the callback.
Default Implementation
Default does nothing.
Declaration
Swift
func subscribedTo(_: RVS_GeneralObservableProtocol)
-
unsubscribedFrom(_:
Default implementation) This is called after being unsubscribed from an Observable.
This is called after the Observable’s
observer(_:, didSubscribe:)
method was called.In the default implementation, this is called in the unsubscription execution context, so that will be the thread used for the callback.
Default Implementation
Default does nothing.
Declaration
Swift
func unsubscribedFrom(_: RVS_GeneralObservableProtocol)