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)
}
)
-
Undocumented
Declaration
Swift
public typealias T = T
-
Undocumented
Declaration
Swift
public typealias E = Never
-
Undocumented
Declaration
Swift
public let key: NodeKey
-
Undocumented
Declaration
Swift
public let get: (StateGetter) throws -> T
-
Undocumented
Declaration
Swift
public func getValue(_ accessor: StateGetter) throws -> T
-
Undocumented
Declaration
Swift
public func setValue(context: MutableContext, newValue: T)