Store concepts in detail

    Note that attempting to access state is not supported in IE11 and will immediately throw an error.

    The StoreProvider accepts three properties

    • renderer: A render function that has the store injected to access state and pass processes to child widgets.
    • stateKey: The key of the state in the registry.
    • paths (optional): A function to connect the provider to sections of the state.

    The StoreProvider has two main ways to trigger invalidation and cause a rerender.

    1. The recommended approach is to register paths by passing the property to the provider to ensure invalidation only occurs when relevant state changes.
    2. A catch-all when no paths are defined for the container, it will invalidate when any data changes in the store.

    A Process has an execution lifecycle that defines the flow of the behavior being defined.

    1. If a transformer is present it gets executed first to transform the payload
    2. before middleware get executed synchronously in order
    3. commands get executed in the order defined
    4. If an exception is thrown during commands, no more commands get executed and the current set of operations are not applied
    5. after middleware get executed synchronously in order

    Multiple middlewares may get defined by providing a list. Middlewares get called synchronously in the order listed.

    Before

    A before middleware block gets passed a payload and a reference to the store.

    After

    An after middleware block gets passed an error (if one occurred) and the of a process.

    The result implements the ProcessResult interface to provide information about the changes applied to the store and provide access to that store.

    • executor - allows additional processes to run against the store
    • store - a reference to the store
    • operations - a list of applied operations
    • undoOperations - a list of operations that can be used to reverse the applied operations
    • apply - the apply method from the store
    • payload - the provided payload

    The Store has an onChange(path, callback) method that takes a path or an array of paths and invokes a callback function whenever that state changes.

    The Store also has an event that fires any time the store changes.