lazy method

FlutterEffect lazy(
  1. void effect(), {
  2. JoltDebugFn? onDebug,
})

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
  • onDebug: Optional debug callback for reactive system debugging

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

FlutterEffect lazy(void Function() effect, {JoltDebugFn? onDebug}) {
  return useAutoDispose(() => FlutterEffect.lazy(effect, onDebug: onDebug));
}