1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Use Volatile State and Lifecycle Methods to Manage Private State

    reactReact
    ^16.0.0
    mobxMobX
    ^3.0.0

    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