Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For example, you can wrap a promise such that when it finally resolves, it checks an isCancelled flag and rejects instead so that your .then callbacks aren't run.

It's not about cancelling any potential inflight action within the promise itself.

In this case, you don't want the callback to run after the react component unmounts, nor do you want to hold a reference to the component:

    promise
        .then(value => this.setState({ value }))


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: