react-native-navigation的迁移库

Lifecycle.ts 859B

1234567891011121314151617181920212223242526272829303132
  1. export class Lifecycle {
  2. private store;
  3. constructor(store) {
  4. this.store = store;
  5. this.componentDidAppear = this.componentDidAppear.bind(this);
  6. this.componentDidDisappear = this.componentDidDisappear.bind(this);
  7. this.onNavigationButtonPressed = this.onNavigationButtonPressed.bind(this);
  8. }
  9. private componentDidAppear(id) {
  10. const ref = this.store.getRefForComponentId(id);
  11. if (ref && ref.didAppear) {
  12. ref.didAppear();
  13. }
  14. }
  15. private componentDidDisappear(id) {
  16. const ref = this.store.getRefForComponentId(id);
  17. if (ref && ref.didDisappear) {
  18. ref.didDisappear();
  19. }
  20. }
  21. private onNavigationButtonPressed(params) {
  22. const ref = this.store.getRefForComponentId(params.componentId);
  23. if (ref && ref.onNavigationButtonPressed) {
  24. ref.onNavigationButtonPressed(params.buttonId);
  25. }
  26. }
  27. }