RxCocoa/Traits

  • Trait for Observable/ObservableType that represents event on UI element.

    It’s properties are:

    • it never fails
    • it won’t send any initial value on subscription
    • it will Complete sequence on control being deallocated
    • it never errors out
    • it delivers events on MainScheduler.instance

    The implementation of ControlEvent will ensure that sequence of events is being subscribed on main scheduler (subscribeOn(ConcurrentMainScheduler.instance) behavior).

    It is implementor’s responsibility to make sure that that all other properties enumerated above are satisfied.

    If they aren’t, then using this trait communicates wrong properties and could potentially break someone’s code.

    In case events observable sequence that is being passed into initializer doesn’t satisfy all enumerated properties, please don’t use this unit.

    See more

    Declaration

    Swift

    public struct ControlEvent<PropertyType> : ControlEventType
  • Trait for Observable/ObservableType that represents property of UI element.

    Sequence of values only represents initial control value and user initiated value changes. Programatic value changes won’t be reported.

    It’s properties are:

    • it never fails
    • shareReplay(1) behavior
      • it’s stateful, upon subscription (calling subscribe) last element is immediately replayed if it was produced
    • it will Complete sequence on control being deallocated
    • it never errors out
    • it delivers events on MainScheduler.instance

    The implementation of ControlProperty will ensure that sequence of values is being subscribed on main scheduler (subscribeOn(ConcurrentMainScheduler.instance) behavior).

    It is implementor’s responsibility to make sure that that all other properties enumerated above are satisfied.

    If they aren’t, then using this trait communicates wrong properties and could potentially break someone’s code.

    In case values observable sequence that is being passed into initializer doesn’t satisfy all enumerated properties, please don’t use this unit.

    See more

    Declaration

    Swift

    public struct ControlProperty<PropertyType> : ControlPropertyType
  • 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 main thread

    UIBindingObserver doesn’t retain target interface and in case owned interface element is released, element isn’t bound.

    In case event binding is attempted from non main dispatch queue, event binding will be dispatched async to main dispatch queue.

    See more

    Declaration

    Swift

    public final class UIBindingObserver<UIElementType, Value> : ObserverType where UIElementType: AnyObject