ReactiveProperties

public struct ReactiveProperties<Object> where Object : NSObject, Object : Retainer

ReactiveProperties is an adaptor for reactive properties.

  • a getter that could be provided as customization point

    Declaration

    Swift

    public typealias CustomGetter<T> = (Object) -> T?
  • a setter that could be provided as customization point

    Declaration

    Swift

    public typealias CustomSetter<T> = (Object, T) -> Void
  • Sink that refers to write-only WKWebView.load(_:)

    Declaration

    Swift

    var loadRequest: Sink<URLRequest, Void> { get }
  • Sink that refers to write-only WKWebView.loadFileURL(_:, allowingReadAccessTo:)

    Declaration

    Swift

    @available(OSX 10.11, iOS 9, *)
    var loadFileURL: Sink<(url: URL, readAccessURL: URL), Void> { get }
  • Sink that refers to write-only WKWebView.loadHTMLString(_:, baseURL:)

    Declaration

    Swift

    var loadHTMLString: Sink<(string: String, baseURL: URL?), Void> { get }
  • Sink that refers to write-only load(_:, mimeType:, characterEncodingName:, baseURL:)

    Declaration

    Swift

    @available(OSX 10.11, iOS 9, *)
    var loadData: Sink<(data: Data, mimeType: String, characterEncodingName: String, baseURL: URL), Void> { get }
  • 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,
      allowSettingSameValue: Bool = false,
      channelBufferSize: Int = 1,
      customGetter: CustomGetter<T?>? = nil,
      customSetter: CustomSetter<T?>? = nil
      ) -> ProducerProxy<T?, Void>

    Parameters

    keyPath

    to observe.

    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>,
      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.

    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,
      channelBufferSize: Int = 1,
      customGetter: CustomGetter<T>? = nil
      ) -> Channel<T?, Void>

    Parameters

    keyPath

    to observe.

    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>,
      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.

    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 a sink that wraps specified setter

    Declaration

    Swift

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

    Parameters

    setter

    to use with sink

    Return Value

    constructed sink