2019-03-19 15:42:25 +00:00
|
|
|
// @flow
|
|
|
|
|
2022-09-27 07:10:28 +00:00
|
|
|
import { APP_STATE_CHANGED, _SET_APP_STATE_LISTENER } from './actionTypes';
|
2017-02-08 11:37:52 +00:00
|
|
|
|
|
|
|
/**
|
2017-02-10 16:13:39 +00:00
|
|
|
* Sets the listener to be used with React Native's AppState API.
|
2017-02-08 11:37:52 +00:00
|
|
|
*
|
2017-02-10 16:13:39 +00:00
|
|
|
* @param {Function} listener - Function to be set as the change event listener.
|
|
|
|
* @protected
|
|
|
|
* @returns {{
|
|
|
|
* type: _SET_APP_STATE_LISTENER,
|
|
|
|
* listener: Function
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function _setAppStateListener(listener: ?Function) {
|
|
|
|
return {
|
|
|
|
type: _SET_APP_STATE_LISTENER,
|
|
|
|
listener
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-03-28 03:50:47 +00:00
|
|
|
/**
|
|
|
|
* Signals that the App state has changed (in terms of execution state). The
|
|
|
|
* application can be in 3 states: 'active', 'inactive' and 'background'.
|
|
|
|
*
|
|
|
|
* @param {string} appState - The new App state.
|
|
|
|
* @public
|
|
|
|
* @returns {{
|
|
|
|
* type: APP_STATE_CHANGED,
|
|
|
|
* appState: string
|
|
|
|
* }}
|
|
|
|
* @see {@link https://facebook.github.io/react-native/docs/appstate.html}
|
|
|
|
*/
|
|
|
|
export function appStateChanged(appState: string) {
|
|
|
|
return {
|
|
|
|
type: APP_STATE_CHANGED,
|
|
|
|
appState
|
|
|
|
};
|
|
|
|
}
|