@espressif/rainmaker-base-cdf
    Preparing search index...

    Class ESPCDF

    The root store that manages all individual stores.

    Index

    Constructors

    Properties

    instance: ESPCDF | null = null

    Accessors

    automationStore: default
    groupStore: default
    • get isSnapshot(): boolean

      true while the tree was restored from disk and no live sync has completed yet.

      Returns boolean

    nodeStore: default
    sceneStore: default
    scheduleStore: default
    sdkAdaptorRegistry: AdaptorRegistry
    subscriptionStore: default
    treeVersion: number

    Bumped by every store action, synchronizer and event handler that changes the home tree (groups, nodes, params). Cheap to watch: the snapshot persister reacts to this counter instead of tracking the whole tree.

    userStore: default

    Methods

    • Gets an SDK adaptor by identifier.

      Parameters

      • adaptorIdentifier: string

        The identifier of the adaptor to retrieve

      Returns ESPSDKAdaptor

      The SDK adaptor instance

    • Adds a custom store to the root store.

      Parameters

      • storeName: string

        The name of the custom store.

      • StoreClass: new (rootStore: ESPCDF) => any

        The class of the custom store.

        Example:

        import { makeAutoObservable, action } from "mobx";
        import { CDF } from "./index";

        class CustomStore {
        rootStore: CDF;
        customValue = "custom value";

        constructor(rootStore: CDF) {
        this.rootStore = rootStore;
        makeAutoObservable(this);
        }

        @action setCustomValue(value: string) {
        this.customValue = value;
        }
        }

        store.addStore("customStore", CustomStore);

      Returns void

    • Deletes the snapshot of the signed-in user (logout, account deletion).

      Returns Promise<void>

    • Releases every entity subscription held by this instance's stores.

      Each store owns its synchronizer as a private field, so teardown has to be forwarded store by store — there is no way to reach them from outside.

      Returns void

    • Returns the identifier of the currently active SDK adaptor, or null if none is set.

      Returns string | null

      The active adaptor identifier, or null

    • Restores the tree from disk when the store is empty and a usable snapshot exists for this adaptor and user. Returns true when something was restored.

      Returns Promise<boolean>

    • Records that the home tree changed. Called by the stores, synchronizers and event handlers.

      Returns void

    • Saves the current tree to disk. Returns false when snapshots are off, there is nothing to save, or the content already on disk is the same.

      Returns Promise<boolean>

    • Tears down the singleton so the next initCDF builds a fresh one.

      getInstance returns the cached instance and ignores the config it is handed, so a host that needs to re-initialise against a DIFFERENT backend (a deployment switch) must clear the singleton first or it silently keeps running on the previous backend's stores.

      Returns void