lazy method

  1. @defineHook
FlutterEffect lazy(
  1. void effect(), {
  2. JoltDebugOption? debug,
})

Creates a Flutter effect hook that runs immediately upon creation.

This method is a convenience constructor for creating a Flutter effect with lazy set to true. The effect will execute once immediately when created, then automatically re-run at frame end whenever its reactive dependencies change.

Parameters:

  • effect: The effect function to execute
  • debug: Optional debug options

Returns: A FlutterEffect that executes immediately

Example:

setup(context, props) {
  final count = useSignal(10);

  useFlutterEffect.lazy(() {
    print('Count is: ${count.value}'); // Executes immediately
  });

  return () => Text('Count: ${count.value}');
}

Implementation

@defineHook
FlutterEffect lazy(void Function() effect, {JoltDebugOption? debug}) {
  return useHook(_UseFlutterEffectHook(effect, true, debug));
}