ComposableMutablePropertyProtocol

public protocol ComposableMutablePropertyProtocol : MutablePropertyProtocol

Represents a mutable property that can be safety composed by exposing its synchronization mechanic through the defined closure-based interface.

  • Atomically performs an arbitrary action using the current value of the variable.

    Declaration

    Swift

    func withValue<Result>(_ action: (Value) throws -> Result) rethrows -> Result

    Parameters

    action

    A closure that accepts current property value.

    Return Value

    the result of the action.

  • Atomically modifies the variable.

    Declaration

    Swift

    func modify<Result>(_ action: (inout Value) throws -> Result) rethrows -> Result

    Parameters

    action

    A closure that accepts old property value and returns a new property value.

    Return Value

    The result of the action.