Skip to content

Commit

Permalink
Remove manual binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Eko Mirhard committed Apr 13, 2017
1 parent 276bb00 commit af6abd5
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/components/posture/PostureMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ class PostureMonitor extends Component {
// Debounce update of user posture threshold setting to limit the number of API requests
this.updateUserPostureThreshold = debounce(this.updateUserPostureThreshold, 1000);
this.backAndroidListener = null;

// Manually bind these methods to ensure valid instance state
// especially after interacting with foreground session controls
this.pauseSession = this.pauseSession.bind(this);
this.resumeSession = this.resumeSession.bind(this);
}

componentWillMount() {
Expand Down Expand Up @@ -183,9 +178,9 @@ class PostureMonitor extends Component {
this.sessionStateListener = SessionControlServiceEvents.addListener('SessionState', event => {
if (event.hasActiveSession) {
// There is currently an active session running on the device, resume session
// only if we are not on the Alert scene and the session's paused
// only if we are not on the Alert scene
if (this.props.currentRoute.name === routes.postureMonitor.name
&& this.state.sessionState !== sessionStates.RUNNING) {
&& this.state.sessionState === sessionStates.RUNNING) {
this.resumeSession();
}
} else {
Expand Down Expand Up @@ -604,6 +599,7 @@ class PostureMonitor extends Component {
});
}

@autobind
pauseSession() {
if (!this.state.hasPendingSessionOperation) {
this.setState({ hasPendingSessionOperation: true });
Expand Down Expand Up @@ -640,6 +636,7 @@ class PostureMonitor extends Component {
}
}

@autobind
resumeSession() {
if (!this.state.hasPendingSessionOperation) {
this.setState({ hasPendingSessionOperation: true });
Expand Down

0 comments on commit af6abd5

Please sign in to comment.