Skip to content

Commit dfc5650

Browse files
committed
broadcasting events based on navigator actions
1 parent eb79e9e commit dfc5650

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ class Router extends React.Component {
4343
onBack(navigator) {
4444
if (this.state.route.index > 0) {
4545
navigator.pop();
46+
this.emitter.emit('pop');
4647
}
4748
}
4849

4950
onForward(nextRoute, navigator) {
5051
navigator.push(
5152
Object.assign(nextRoute, { index: this.state.route.index + 1 || 1 })
5253
);
54+
this.emitter.emit('push', nextRoute);
5355
}
5456

5557
setRightProps(props) {
@@ -77,27 +79,31 @@ class Router extends React.Component {
7779
navigator.push(
7880
Object.assign(nextRoute, { index: this.state.route.index + 1 || 1 })
7981
);
82+
this.emitter.emit('push', nextRoute);
8083
}.bind(this);
8184

8285
const replaceRoute = function replaceRoute(nextRoute) {
8386
navigator.replace(
8487
Object.assign(nextRoute, { index: this.state.route.index || 0 })
8588
);
89+
this.emitter.emit('replace', nextRoute);
8690
}.bind(this);
8791

8892
const resetToRoute = function resetToRoute(nextRoute) {
8993
navigator.resetTo(
9094
Object.assign(nextRoute, { index: 0 })
9195
);
92-
};
96+
this.emitter.emit('resetTo', nextRoute);
97+
}.bind(this);
9398

9499
const goBackwards = function goBackwards() {
95100
this.onBack(navigator);
96101
}.bind(this);
97102

98103
const goToFirstRoute = function goToFirstRoute() {
99104
navigator.popToTop();
100-
};
105+
this.emitter.emit('popToTop');
106+
}.bind(this);
101107

102108
const setRightProps = function setRightProps(props) {
103109
this.setState({ rightProps: props });

0 commit comments

Comments
 (0)