Przeglądaj źródła

Update screen-api.md

Guy Carmeli 7 lat temu
rodzic
commit
59c9b5f671
1 zmienionych plików z 28 dodań i 0 usunięć
  1. 28
    0
      docs/screen-api.md

+ 28
- 0
docs/screen-api.md Wyświetl plik

@@ -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