observe<GlobalState, NullableState, GlobalAction, A> static method

IfLetStore<NullableState, A> observe<GlobalState, NullableState, GlobalAction, A>({
  1. Key? key,
  2. required Store<GlobalState, GlobalAction> store,
  3. required Widget builder(
    1. BuildContext context,
    2. Store<NullableState, A> store
    ),
  4. required NullableState? toNullableState(
    1. GlobalState state
    ),
  5. required GlobalAction toGlobalAction(
    1. A action
    ),
  6. Widget orElse(
    1. BuildContext context
    )?,
})
override

Creates an IfLetStore by projecting nullable state from a global store.

Uses toNullableState to extract the optional child state and toGlobalAction to embed child actions into the global action type.

Implementation

static IfLetStore<NullableState, A> observe<GlobalState, NullableState, GlobalAction, A>({
  Key? key,
  required Store<GlobalState, GlobalAction> store,
  required Widget Function(BuildContext context, Store<NullableState, A> store) builder,
  required NullableState? Function(GlobalState state) toNullableState,
  required GlobalAction Function(A action) toGlobalAction,
  Widget Function(BuildContext context)? orElse,
}) =>
    IfLetStore(
      store: store.scope(
        toLocalState: toNullableState,
        toGlobalAction: toGlobalAction,
      ),
      builder: builder,
      orElse: orElse,
    );