summaryrefslogtreecommitdiff
path: root/app/presentation/screens/screen.js
blob: 926fd245ee84d8f15b3e2810743473fcd7c31802 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { Component } from 'react';

export default class Screen extends Component {
  componentDidMount() {
    this.eventsOfInterest().forEach((event) => {
      this.props.eventAggregator.subscribe(event, this);
    });
  }

  componentWillUnmount() {
    this.props.eventAggregator.unsubscribe(this);
  }

  publish(event) {
    this.props.eventAggregator.publish(event);
  }

  loadScreen(screen, params = {}) {
    this.props.navigator.push({ component: screen, params });
  }

  eventsOfInterest() {
    if (this.state == null || this.state.eventsOfInterest == undefined) {
      return [];
    }
    return this.state.eventsOfInterest;
  }

  resolve(component) {
    return this.props.registry.resolve(component);
  }
}