Skip to content

Commit 35c9f0a

Browse files
committed
Merge pull request #17 from ericraio/master
broadcasting events based on navigator actions
2 parents 331388c + dfc5650 commit 35c9f0a

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
@@ -64,13 +64,15 @@ class Router extends React.Component {
6464
onBack(navigator) {
6565
if (this.state.route.index > 0) {
6666
navigator.pop();
67+
this.emitter.emit('pop');
6768
}
6869
}
6970

7071
onForward(nextRoute, navigator) {
7172
navigator.push(
7273
Object.assign(nextRoute, { index: this.state.route.index + 1 || 1 })
7374
);
75+
this.emitter.emit('push', nextRoute);
7476
}
7577

7678
setRightProps(props) {
@@ -98,27 +100,31 @@ class Router extends React.Component {
98100
navigator.push(
99101
Object.assign(nextRoute, { index: this.state.route.index + 1 || 1 })
100102
);
103+
this.emitter.emit('push', nextRoute);
101104
}.bind(this);
102105

103106
const replaceRoute = function replaceRoute(nextRoute) {
104107
navigator.replace(
105108
Object.assign(nextRoute, { index: this.state.route.index || 0 })
106109
);
110+
this.emitter.emit('replace', nextRoute);
107111
}.bind(this);
108112

109113
const resetToRoute = function resetToRoute(nextRoute) {
110114
navigator.resetTo(
111115
Object.assign(nextRoute, { index: 0 })
112116
);
113-
};
117+
this.emitter.emit('resetTo', nextRoute);
118+
}.bind(this);
114119

115120
const goBackwards = function goBackwards() {
116121
this.onBack(navigator);
117122
}.bind(this);
118123

119124
const goToFirstRoute = function goToFirstRoute() {
120125
navigator.popToTop();
121-
};
126+
this.emitter.emit('popToTop');
127+
}.bind(this);
122128

123129
const setRightProps = function setRightProps(props) {
124130
this.setState({ rightProps: props });

0 commit comments

Comments
 (0)