Go ProSign in
Manage Application State with Mobx-state-tree

Manage Application State with Mobx-state-tree


    Use Volatile State and Lifecycle Methods to Manage Private State

    Michel WeststrateMichel Weststrate

    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

    You must be a Member to view code