BuiltinSideEffects extension

A collection of builtin side effects.

on

Methods

api() SideEffectApi

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Convenience side effect that gives a copy of the SideEffectApi.
asListener() → void

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Declares the associated capsule as a non-idempotent listener.
callonce<T>(T callback()) → T

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Side effect that calls the supplied callback once, on the first build.
data<T>(T initial) ValueWrapper<T>

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Keeps track of some data that can be stateful. You may set the value of returned ValueWrapper both:
disposable<T>(T init(), void dispose(T), [List<Object?> dependencies = const []]) → T

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

A shortcut over memo and effect to handle disposable objects. Specifically, this:
effect(void Function()? effect(), [List<Object?>? dependencies]) → void

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Equivalent to the useEffect hook from React. See https://react.dev/reference/react/useEffect
future<T>(Future<T> future) AsyncValue<T>

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Consumes a Future and watches the given future.
hydrate<T>(T? newData, {required Future<T> read(), required Future<void> write(T)}) AsyncValue<T>

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

A mechanism to persist changes made to some provided state. Unlike persist, hydrate allows you to pass in the state to persist, if there is one, to enable easier composition with other side effects.
invalidatableFuture<T>(Future<T> futureFactory()) → (AsyncValue<T> Function(), void Function())

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

A side effect that allows you to watch a future lazily (by invoking the first callback) that can be invalidated lazily (by invoking the second callback).
isFirstBuild() bool

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Returns true on the first build and false on subsequent builds.
lazyData<T>(T init()) ValueWrapper<T>

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Keeps track of some data that can be stateful. You may set the value of returned ValueWrapper both:
lazyState<T>(T init()) → (T, void Function(T))

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Side effect that provides a way for capsules to contain some state, where the initial state is computationally expensive.
lazyStateGetterSetter<T>(T init()) ValueWrapper<T>

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Side effect that provides a way for capsules to contain some state, where the initial state is computationally expensive. Further, instead of returning the state directly, this instead returns a getter that is safe to capture in closures.
lazyValue<T>(T init()) → T

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Side effect that provides a way for capsules to hold onto some value between builds, where the initial value is computationally expensive.
memo<T>(T memo(), [List<Object?> dependencies = const []]) → T

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Equivalent to the useMemo hook from React. See https://react.dev/reference/react/useMemo
mutation<T>() Mutation<T>

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Allows you to trigger and watch Futures (called mutations, since they often mutate some state) from within the build function. See the documentation for more.
nullableFuture<T>(Future<T>? future) AsyncValue<T>?

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Consumes a nullable Future and watches the given future.
nullableStream<T>(Stream<T>? stream) AsyncValue<T>?

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Consumes a nullable Stream and watches the given stream.
persist<T>({required Future<T> read(), required Future<void> write(T)}) → (AsyncValue<T>, void Function(T))

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

A mechanism to persist changes made in state that manages its own state. See the docs for usage information.
previous<T>(T current) → T?

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Returns the previous value passed into previous, or null on first build.
rebuilder() → void Function([void sideEffectMutation(void cancelRebuild())?])

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Convenience side effect that gives a copy of SideEffectApi.rebuild.
reducer<State, Action>(Reducer<State, Action> reducer, State initialState) → (State, void Function(Action))

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

A simple implementation of the reducer pattern as a side effect.
refreshableFuture<T>(Future<T> futureFactory()) → (AsyncValue<T>, Future<T> Function())

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

A side effect that allows you to watch a future that can be refreshed by invoking the supplied callback (which will also give you an updated copy of that future).
replay<T>() → (T?, void Function(T), {void Function()? redo, void Function()? undo})

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Provides a way to keep track of some state while also providing "undo" and "redo" operations. This side effect is analogous to the replay bloc library, if you have heard of it.
state<T>(T initial) → (T, void Function(T))

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Side effect that provides a way for capsules to contain some state.
stateGetterSetter<T>(T initial) ValueWrapper<T>

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Side effect that provides a way for capsules to contain some state. Further, instead of returning the state directly, this instead returns a getter that is safe to capture in closures.
stream<T>(Stream<T> stream) AsyncValue<T>

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Consumes a Stream and watches the given stream.
transactionRunner() → void Function(void ())

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Convenience side effect that gives a copy of SideEffectApi.runTransaction.
value<T>(T initial) → T

Available on SideEffectRegistrar, provided by the BuiltinSideEffects extension

Side effect that provides a way for capsules to hold onto some value between builds.