useAppLifecycleState function

  1. @defineHook
ReadonlySignal<AppLifecycleState?> useAppLifecycleState({
  1. AppLifecycleState? initialState,
  2. void onChange(
    1. AppLifecycleState state
    )?,
})

Listens to application lifecycle state changes

Returns a reactive Signal representing the current application lifecycle state

Implementation

@defineHook
ReadonlySignal<AppLifecycleState?> useAppLifecycleState({
  AppLifecycleState? initialState,
  void Function(AppLifecycleState state)? onChange,
}) {
  final observer = useHook(
      _AppLifecycleObserver(initialState: initialState, onChange: onChange));

  return observer.readonly();
}