MutableSelector

public struct MutableSelector<T> : SyncSelectorNode where T : Equatable
extension MutableSelector: Writeable

MutableSelector is a bi-directional sync selector receives the incoming value as a parameter and can use that to propagate the changes back upstream along the data-flow graph.

 let tempFahrenheitState = atom(32)
 let tempCelsiusSelector = selector(
      get: { get in
        let fahrenheit = accessor.get(tempFahrenheitState)
        return (fahrenheit - 32) * 5 / 9
      },
      set: { context, newValue in
        let newFahrenheit = (newValue * 9) / 5 + 32
        context.accessor.set(tempFahrenheitState, newFahrenheit)
      }
)
  • T

    Undocumented

    Declaration

    Swift

    public typealias T = T
  • E

    Undocumented

    Declaration

    Swift

    public typealias E = Never
  • key

    Undocumented

    Declaration

    Swift

    public let key: NodeKey
  • get

    Undocumented

    Declaration

    Swift

    public let get: (StateGetter) throws -> T
  • set

    Undocumented

    Declaration

    Swift

    public let set: SetBody<T>
  • Undocumented

    Declaration

    Swift

    public init(key: NodeKey, get: @escaping SyncGet<T>, set: @escaping SetBody<T>)
  • Undocumented

    Declaration

    Swift

    public func getValue(_ accessor: StateGetter) throws -> T

Sync Selector