Retainer

public protocol Retainer : AnyObject

An object that can extend lifetime of another objects up to deinit or notify deinit

  • Extends lifetime of specified object

    Declaration

    Swift

    func releaseOnDeinit(_ object: AnyObject)
  • calls specified block on deinit

    Declaration

    Swift

    func notifyDeinit(_ block: @escaping () -> Void)
  • CustomGetter Extension method

    a getter that could be provided as customization point

    Declaration

    Swift

    typealias CustomGetter<T> = (Self) -> T?
  • CustomSetter Extension method

    a setter that could be provided as customization point

    Declaration

    Swift

    typealias CustomSetter<T> = (Self, T) -> Void
  • makes an UpdatableProperty<T?> for specified key path.

    UpdatableProperty is a kind of Producer so you can:

    • subscribe for updates
    • transform using map, flatMap, filter, debounce, distinct, …
    • update manually with update() method
    • bind Channel to an UpdatableProperty using Channel.bind

    Make sure that keyPath refers to KVO-compliant property.

    • Make sure that properties defined in swift have dynamic attribute.
    • Make sure that methods class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String> return correct values for read-only properties

    Declaration

    Swift

    func updatable<T>(
      forKeyPath keyPath: String,
      executor: Executor,
      from originalExecutor: Executor? = nil,
      observationSession: ObservationSession? = nil,
      allowSettingSameValue: Bool = false,
      channelBufferSize: Int = 1,
      customGetter: CustomGetter<T?>? = nil,
      customSetter: CustomSetter<T?>? = nil
      ) -> ProducerProxy<T?, Void>

    Parameters

    keyPath

    to observe.

    executor

    to subscribe and update value on

    originalExecutor

    Executor you calling this method on. Specifying this argument will allow to perform syncronous executions on strictAsync: false Executors. Use default value or nil if you are not sure about an Executor you calling this method on.

    observationSession

    is an object that helps to control observation

    allowSettingSameValue

    set to true if you want to set a new value event if it is equal to an old one

    channelBufferSize

    size of the buffer within returned channel

    customGetter

    provides a custom getter to use instead of value(forKeyPath:) call

    customSetter

    provides a custom getter to use instead of setValue(_: forKeyPath:) call

    Return Value

    an UpdatableProperty<T?> bound to observe and update specified keyPath

  • makes an UpdatableProperty<T> for specified key path.

    UpdatableProperty is a kind of Producer so you can:

    • subscribe for updates
    • transform using map, flatMap, filter, debounce, distinct, …
    • update manually with update() method
    • bind Channel to an UpdatableProperty using Channel.bind

    Make sure that keyPath refers to KVO-compliant property.

    • Make sure that properties defined in swift have dynamic attribute.
    • Make sure that methods class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String> return correct values for read-only properties

    Declaration

    Swift

    func updatable<T>(
      forKeyPath keyPath: String,
      onNone: UpdateWithNoneHandlingPolicy<T>,
      executor: Executor,
      from originalExecutor: Executor? = nil,
      observationSession: ObservationSession? = nil,
      allowSettingSameValue: Bool = false,
      channelBufferSize: Int = 1,
      customGetter: CustomGetter<T>? = nil,
      customSetter: CustomSetter<T>? = nil
      ) -> ProducerProxy<T, Void>

    Parameters

    keyPath

    to observe.

    onNone

    is a policy of handling None (or nil) value that can arrive from Key-Value observation.

    executor

    to subscribe and update value on

    originalExecutor

    Executor you calling this method on. Specifying this argument will allow to perform syncronous executions on strictAsync: false Executors. Use default value or nil if you are not sure about an Executor you calling this method on.

    observationSession

    is an object that helps to control observation

    allowSettingSameValue

    set to true if you want to set a new value event if it is equal to an old one

    channelBufferSize

    size of the buffer within returned channel

    customGetter

    provides a custom getter to use instead of value(forKeyPath:) call

    customSetter

    provides a custom getter to use instead of setValue(_: forKeyPath:) call

    Return Value

    an UpdatableProperty<T> bound to observe and update specified keyPath

  • makes an Updating<T?> for specified key path.

    Updating is a kind of Channel so you can:

    • subscribe for updates
    • transform using map, flatMap, filter, debounce, distinct, …

    Make sure that keyPath refers to KVO-compliant property.

    • Make sure that properties defined in swift have dynamic attribute.
    • Make sure that methods class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String> return correct values for read-only properties

    Declaration

    Swift

    func updating<T>(
      forKeyPath keyPath: String,
      executor: Executor,
      from originalExecutor: Executor? = nil,
      observationSession: ObservationSession? = nil,
      channelBufferSize: Int = 1,
      customGetter: CustomGetter<T?>? = nil
      ) -> Channel<T?, Void>

    Parameters

    keyPath

    to observe.

    executor

    to subscribe and update value on

    originalExecutor

    Executor you calling this method on. Specifying this argument will allow to perform syncronous executions on strictAsync: false Executors. Use default value or nil if you are not sure about an Executor you calling this method on.

    observationSession

    is an object that helps to control observation

    channelBufferSize

    size of the buffer within returned channel

    customGetter

    provides a custom getter to use instead of value(forKeyPath:) call

    Return Value

    an Updating<T?> bound to observe and update specified keyPath

  • makes an Updating<T> for specified key path.

    Updating is a kind of Channel so you can:

    • subscribe for updates
    • transform using map, flatMap, filter, debounce, distinct, …

    Make sure that keyPath refers to KVO-compliant property.

    • Make sure that properties defined in swift have dynamic attribute.
    • Make sure that methods class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String> return correct values for read-only properties

    Declaration

    Swift

    func updating<T>(
      forKeyPath keyPath: String,
      onNone: UpdateWithNoneHandlingPolicy<T>,
      executor: Executor,
      from originalExecutor: Executor? = nil,
      observationSession: ObservationSession? = nil,
      channelBufferSize: Int = 1,
      customGetter: CustomGetter<T>? = nil
      ) -> Channel<T, Void>

    Parameters

    keyPath

    to observe.

    onNone

    is a policy of handling None (or nil) value that can arrive from Key-Value observation.

    executor

    to subscribe and update value on

    originalExecutor

    Executor you calling this method on. Specifying this argument will allow to perform syncronous executions on strictAsync: false Executors. Use default value or nil if you are not sure about an Executor you calling this method on.

    observationSession

    is an object that helps to control observation

    channelBufferSize

    size of the buffer within returned channel

    customGetter

    provides a custom getter to use instead of value(forKeyPath:) call

    Return Value

    an Updating<T> bound to observe and update specified keyPath

  • sink(executor:setter:) Extension method

    Makes a sink that wraps specified setter

    Declaration

    Swift

    func sink<T>(executor: Executor, setter: @escaping CustomSetter<T>) -> Sink<T, Void>

    Parameters

    setter

    to use with sink

    Return Value

    constructed sink

  • makes an Updating<(old: T?, new: T?)> for specified key path. With an Updating you can

    • subscribe for updates
    • transform Updating as any Channel (map, flatMap, filter, debounce, distinct, …)

    Make sure that keyPath refers to KVO-compliant property.

    • Make sure that properties defined in swift have dynamic attribute.
    • Make sure that methods class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String> return correct values for read-only properties

    Declaration

    Swift

    func updatingOldAndNew<T>(
      forKeyPath keyPath: String,
      executor: Executor,
      from originalExecutor: Executor? = nil,
      observationSession: ObservationSession? = nil,
      channelBufferSize: Int = 1
      ) -> Channel<(old: T?, new: T?), Void>

    Parameters

    keyPath

    to observe.

    executor

    to subscribe and update value on

    originalExecutor

    Executor you calling this method on. Specifying this argument will allow to perform syncronous executions on strictAsync: false Executors. Use default value or nil if you are not sure about an Executor you calling this method on.

    observationSession

    is an object that helps to control observation

    channelBufferSize

    size of the buffer within returned channel

    customGetter

    provides a custom getter to use instead of value(forKeyPath:) call

    Return Value

    an Updating<(old: T?, new: T?)> bound to observe and update specified keyPath

  • makes an Updating<[NSKeyValueChangeKey: Any]> for specified key path. With an Updating you can

    • subscribe for updates
    • transform Updating as any Channel (map, flatMap, filter, debounce, distinct, …)

    Make sure that keyPath refers to KVO-compliant property.

    • Make sure that properties defined in swift have dynamic attribute.
    • Make sure that methods class func keyPathsForValuesAffectingValue(forKey key: String) -> Set<String> return correct values for read-only properties

    Declaration

    Swift

    func updatingChanges(
      forKeyPath keyPath: String,
      executor: Executor,
      from originalExecutor: Executor? = nil,
      options: NSKeyValueObservingOptions,
      observationSession: ObservationSession? = nil,
      channelBufferSize: Int = 1
      ) -> Channel<[NSKeyValueChangeKey: Any], Void>

    Parameters

    keyPath

    to observe.

    executor

    to subscribe and update value on

    originalExecutor

    Executor you calling this method on. Specifying this argument will allow to perform syncronous executions on strictAsync: false Executors. Use default value or nil if you are not sure about an Executor you calling this method on.

    observationSession

    is an object that helps to control observation

    channelBufferSize

    size of the buffer within returned channel

    Return Value

    an Updating<[NSKeyValueChangeKey: Any]> bound to observe and update specified keyPath