|
@@ -289,6 +289,34 @@ export default class ExampleScreen extends Component {
|
289
|
289
|
}
|
290
|
290
|
```
|
291
|
291
|
|
|
292
|
+## Listen to visibility events globally
|
|
293
|
+
|
|
294
|
+```js
|
|
295
|
+import {ScreenVisibilityListener as RNNScreenVisibilityListener} from 'react-native-navigation';
|
|
296
|
+
|
|
297
|
+export class ScreenVisibilityListener {
|
|
298
|
+
|
|
299
|
+ constructor() {
|
|
300
|
+ this.listener = new RNNScreenVisibilityListener({
|
|
301
|
+ didAppear: ({screen, startTime, endTime, commandType}) => {
|
|
302
|
+ console.log('screenVisibility', `Screen ${screen} displayed in ${endTime - startTime} millis after [${commandType}]`);
|
|
303
|
+ }
|
|
304
|
+ });
|
|
305
|
+ }
|
|
306
|
+
|
|
307
|
+ register() {
|
|
308
|
+ this.listener.register();
|
|
309
|
+ }
|
|
310
|
+
|
|
311
|
+ unregister() {
|
|
312
|
+ if (this.listener) {
|
|
313
|
+ this.listener.unregister();
|
|
314
|
+ this.listener = null;
|
|
315
|
+ }
|
|
316
|
+ }
|
|
317
|
+}
|
|
318
|
+```
|
|
319
|
+
|
292
|
320
|
# Listening to tab selected events
|
293
|
321
|
In order to listen to `bottomTabSelected` event, set an `onNavigatorEventListener` on screens that are pushed to BottomTab. The event is dispatched to the top most screen pushed to the selected tab's stack.
|
294
|
322
|
|