-
Notifications
You must be signed in to change notification settings - Fork 10
Reducer
Transforms a reducer that works on local state, action, and environment into one that works on
global state, action and environment when the local environment is a subclass of ComposableEnvironment.
It accomplishes this by providing 2 transformations to the method:
func pullback<GlobalState, GlobalAction, GlobalEnvironment>(
state toLocalState: WritableKeyPath<GlobalState, State>,
action toLocalAction: CasePath<GlobalAction, Action>
) -> Reducer<GlobalState, GlobalAction, GlobalEnvironment>
where GlobalEnvironment: ComposableEnvironment -
A writable key path that can get/set a piece of local state from the global state.
-
A case path that can extract/embed a local action into a global action.
Because the environment is ComposableEnvironment, its lifecycle is automatically managed by the library.
For more information about this reducer, see the discussion about the equivalent function using
unbounded environments in swift-composable-architecture.
- toLocalState: A key path that can get/set
StateinsideGlobalState. - toLocalAction: A case path that can extract/embed
ActionfromGlobalAction.
A reducer that works on GlobalState, GlobalAction, GlobalEnvironment.
Transforms a reducer that works on local state, action, and environment into one that works on
global state, action and environmentwhen the local environment is a subclass of ComposableEnvironment.
func pullback<GlobalState, GlobalAction, GlobalEnvironment>(
state toLocalState: CasePath<GlobalState, State>,
action toLocalAction: CasePath<GlobalAction, Action>,
breakpointOnNil: Bool = true,
_ file: StaticString = #file,
_ line: UInt = #line
) -> Reducer<GlobalState, GlobalAction, GlobalEnvironment>
where GlobalEnvironment: ComposableEnvironment It accomplishes this by providing 2 transformations to the method:
-
A case path that can extract/embed a piece of local state from the global state, which is typically an enum.
-
A case path that can extract/embed a local action into a global action.
Because the environment is ComposableEnvironment, its lifecycle is automatically managed by the library.
For more information about this reducer, see the discussion about the equivalent function using
unbounded environments in swift-composable-architecture.
- toLocalState: A case path that can extract/embed
StatefromGlobalState. - toLocalAction: A case path that can extract/embed
ActionfromGlobalAction.
A reducer that works on GlobalState, GlobalAction, GlobalEnvironment.
A version of pullback(state:action) that transforms a reducer that works on
an element into one that works on an identified array of elements, when the local environment is a subclass
ofComposableEnvironment.
func forEach<GlobalState, GlobalAction, GlobalEnvironment, ID>(
state toLocalState: WritableKeyPath<GlobalState, IdentifiedArray<ID, State>>,
action toLocalAction: CasePath<GlobalAction, (ID, Action)>,
breakpointOnNil: Bool = true,
_ file: StaticString = #file,
_ line: UInt = #line
) -> Reducer<GlobalState, GlobalAction, GlobalEnvironment>
where GlobalEnvironment: ComposableEnvironment For more information about this reducer, see the discussion about the equivalent function using
unbounded environments in swift-composable-architecture.
- toLocalState: A key path that can get/set a collection of
Stateelements insideGlobalState. - toLocalAction: A case path that can extract/embed
(Collection.Index, Action)fromGlobalAction. - breakpointOnNil: Raises
SIGTRAPsignal when an action is sent to the reducer but the identified array does not contain an element with the action's identifier. This is generally considered a logic error, as a child reducer cannot process a child action for unavailable child state.
A reducer that works on GlobalState, GlobalAction, GlobalEnvironment.
A version of pullback(state:action:environment:) that transforms a reducer that works on
an element into one that works on a dictionary of element values, when the local environment is a subclass
ofComposableEnvironment.
func forEach<GlobalState, GlobalAction, GlobalEnvironment, Key>(
state toLocalState: WritableKeyPath<GlobalState, [Key: State]>,
action toLocalAction: CasePath<GlobalAction, (Key, Action)>,
breakpointOnNil: Bool = true,
_ file: StaticString = #file,
_ line: UInt = #line
) -> Reducer<GlobalState, GlobalAction, GlobalEnvironment>
where GlobalEnvironment: ComposableEnvironment For more information about this reducer, see the discussion about the equivalent function using
unbounded environments in swift-composable-architecture.
- toLocalState: A key path that can get/set a dictionary of
Statevalues insideGlobalState. - toLocalAction: A case path that can extract/embed
(Key, Action)fromGlobalAction. - breakpointOnNil: Raises
SIGTRAPsignal when an action is sent to the reducer but the identified array does not contain an element with the action's identifier. This is generally considered a logic error, as a child reducer cannot process a child action for unavailable child state.
A reducer that works on GlobalState, GlobalAction, GlobalEnvironment.
Generated at 2022-08-22T21:22:01+0000 using swift-doc 1.0.0-rc.1.