master
1import React, { Component } from 'react';
2
3export default class Screen extends Component {
4 componentDidMount() {
5 this.eventsOfInterest().forEach((event) => {
6 this.props.eventAggregator.subscribe(event, this);
7 });
8 }
9
10 componentWillUnmount() {
11 this.props.eventAggregator.unsubscribe(this);
12 }
13
14 publish(event) {
15 this.props.eventAggregator.publish(event);
16 }
17
18 loadScreen(screen, params = {}) {
19 this.props.navigator.push({ component: screen, params });
20 }
21
22 eventsOfInterest() {
23 if (this.state == null || this.state.eventsOfInterest == undefined) {
24 return [];
25 }
26 return this.state.eventsOfInterest;
27 }
28
29 resolve(component) {
30 return this.props.registry.resolve(component);
31 }
32}