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

    SceneStore - Manages scene operations and state for ESP Rainmaker CDF

    This store handles all scene-related operations including:

    • Scene CRUD operations (Create, Read, Update, Delete)
    • Scene transformation from node configurations
    • Scene activation and synchronization
    • Payload generation for scene operations
    • Interceptor patterns for scene actions

    Indexable

    • [key: string]: any

      Index signature for dynamic property access

    Index

    Constructors

    Accessors

    _scenesByID: { [key: string]: ESPCDFScene }

    Observable map of scenes indexed by scene ID

    Methods

    • Activates multiple scenes concurrently

      This method activates multiple scenes in parallel using Promise.all.

      Parameters

      • sceneIds: string[]

        Array of scene IDs to activate

      Returns Promise<void>

      Resolves when every scene in the list has been activated

      If any scene activation fails

      await sceneStore.activateMultipleScenes(['scene1', 'scene2', 'scene3']);
      
    • Activates a scene by triggering its action

      This method finds the scene by ID and calls its trigger method, which will activate the scene across all its associated nodes.

      Parameters

      • sceneId: string

        The ID of the scene to activate

      Returns Promise<void>

      Resolves when scene.activate() completes for that scene

      If scene is not found or activation fails

      await sceneStore.activateScene('scene123');
      
    • Dynamically adds an observable property to the store

      This method adds a new observable property to the store and automatically creates getter and setter methods for it. The property name is capitalized for the getter/setter methods.

      Parameters

      • propertyName: string

        The name of the property to add

      • initialValue: any

        The initial value for the property

      Returns void

      sceneStore.addProperty('customField', 'initial value');
      sceneStore.setCustomField('new value');
    • Clears all scenes and resets hooks to default values

      This method removes all scenes from the store and resets the beforeSetSceneListHook and afterSetSceneListHook to empty functions.

      Returns void

      sceneStore.clear();
      
    • Deletes multiple scenes by their IDs

      Parameters

      • ids: string[]

        Array of scene IDs to delete

      Returns void

      sceneStore.deleteScenes(['scene1', 'scene2', 'scene3']);
      
    • Retrieves a scene by its ID

      Parameters

      • sceneId: string

        The ID of the scene to retrieve

      Returns ESPCDFScene | null

      The scene object or null if not found

      const scene = sceneStore.getScene('scene123');
      
    • Sets the entire scene list, replacing all existing scenes

      This method replaces all scenes in the store with the provided array. Each scene is made observable and has interceptors set up.

      Parameters

      Returns void

      sceneStore.setSceneList([
      { id: 'scene1', name: 'Scene 1', nodes: [], actions: {} },
      { id: 'scene2', name: 'Scene 2', nodes: [], actions: {} }
      ]);
    • Updates a scene by ID without making it observable

      Parameters

      • id: string

        The scene ID

      • scene: ESPCDFScene

        The scene object to set

      Returns void

      sceneStore.updateSceneByID('scene123', updatedScene);