1 | /**
|
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | *
|
7 | * @format
|
8 | */
|
9 |
|
10 | import {NativeEventSubscription} from '../EventEmitter/RCTNativeAppEventEmitter';
|
11 |
|
12 | export type BackPressEventName = 'hardwareBackPress';
|
13 |
|
14 | /**
|
15 | * Detect hardware back button presses, and programmatically invoke the
|
16 | * default back button functionality to exit the app if there are no
|
17 | * listeners or if none of the listeners return true.
|
18 | * The event subscriptions are called in reverse order
|
19 | * (i.e. last registered subscription first), and if one subscription
|
20 | * returns true then subscriptions registered earlier
|
21 | * will not be called.
|
22 | *
|
23 | * @see https://reactnative.dev/docs/backhandler
|
24 | */
|
25 | export interface BackHandlerStatic {
|
26 | exitApp(): void;
|
27 | addEventListener(
|
28 | eventName: BackPressEventName,
|
29 | handler: () => boolean | null | undefined,
|
30 | ): NativeEventSubscription;
|
31 | removeEventListener(
|
32 | eventName: BackPressEventName,
|
33 | handler: () => boolean | null | undefined,
|
34 | ): void;
|
35 | }
|
36 |
|
37 | export const BackHandler: BackHandlerStatic;
|
38 | export type BackHandler = BackHandlerStatic;
|