Binder
public struct Binder<Value> : ObserverType
Observer that enforces interface binding rules:
- can’t bind errors (in debug builds binding of errors causes
fatalError
in release builds errors are being logged) - ensures binding is performed on a specific scheduler
Binder
doesn’t retain target and in case target is released, element isn’t bound.
By default it binds elements on main scheduler.
-
Declaration
Swift
public typealias Element = Value
-
Initializes
Binder
Declaration
Swift
public init<Target>(_ target: Target, scheduler: ImmediateSchedulerType = MainScheduler(), binding: @escaping (Target, Value) -> Void) where Target : AnyObject
Parameters
target
Target object.
scheduler
Scheduler used to bind the events.
binding
Binding logic.
-
Binds next element to owner view as described in
binding
.Declaration
Swift
public func on(_ event: Event<Value>)
-
Erases type of observer.
Declaration
Swift
public func asObserver() -> AnyObserver<Value>
Return Value
type erased observer.