Become a member
to unlock all features

Create an egghead account to access 5000+ tutorials and resources from expert developers.

Create account

    Use Volatile State and Lifecycle Methods to Manage Private State


    MST has a pretty unique feature: It allows you to capture private state on models, and manage this state by using lifecycle hooks. For example by setting up a WebSocket connection and disposing of the connection automatically as soon as the instance gets removed from the store. In this lesson, we will leverage cancellable fetches to abort in-flight requests when appropriate

    In this lesson you will learn:

    • Aborting window.fetch requests :-).
    • Storing private, volatile, internal state in the function closure
    • A second life-cycle hook: beforeDestroy