useEffectScope top-level property

JoltEffectScopeHookCreator useEffectScope
final

Creates an effect scope hook for managing effect lifecycles.

An effect scope allows you to group related effects together and dispose them all at once. Useful for component-based architectures.

Parameters:

  • fn: Optional function to execute within the scope context
  • keys: Optional keys for hook memoization
  • debug: Optional debug options

Returns: An EffectScope for managing effect lifecycles

Example:

Widget build(BuildContext context) {
  useEffectScope(fn: (scope) {
    scope.run(() {
      final signal = Signal(0);
      Effect(() => print(signal.value));

      onScopeDispose(() => print('Scope cleaned up'));
    });
  });

  return Text('Component with scoped effects');
}

Implementation

final useEffectScope = JoltEffectScopeHookCreator._();