Operations run one at a time, in call order, each checked against the revision the previous one left, so a burst of clicks never interleaves.

A write the store refuses because the catalog moved (another tab, another control on the page) is tried again on the newer catalog when what it acts on is unchanged there: the held layout for a save, the named layout for rename, duplicate, remove and open. Only a change to that is a conflict.

interface LayoutsController {
    store: WorkspaceStore;
    changed(): void;
    destroy(): void;
    duplicate(id: string, name: string): Promise<WorkspaceDocument>;
    flush(): Promise<void>;
    open(id: string): Promise<LayoutApplyReport>;
    overwrite(): Promise<WorkspaceDocument>;
    reload(): Promise<WorkspaceCatalog>;
    remove(id: string): Promise<void>;
    rename(id: string, name: string): Promise<void>;
    save(): Promise<WorkspaceDocument>;
    saveAs(name: string): Promise<WorkspaceDocument>;
    setAutosave(enabled: boolean): Promise<void>;
    state(): LayoutsState;
    subscribe(listener: (state: LayoutsState) => void): () => void;
}

Properties

Methods

  • Tell the controller the target may have changed, for a target without subscribe.

    Returns void

  • Stop listening. A queued operation rejects; a pending autosave is dropped, so flush() first to keep it.

    Returns void

  • Compare the target with its layout now, autosave if due, and wait for every queued operation.

    Returns Promise<void>

  • Show a saved layout and record it as active and recent, unless it already is. A change still waiting for the quiet period is autosaved into the layout being left first; when that write fails this rejects and changes nothing, and opening again goes ahead without it. A refused apply resolves with its report and leaves the target and the held layout as they were; when the store refuses the record, the previous layout goes back on the target and this rejects. It rejects too while the target is suspended.

    Parameters

    • id: string

    Returns Promise<LayoutApplyReport>

  • Read the catalog again, and resolve with a copy of it. The target is not touched. A paused autosave resumes, unless the held layout conflicts. After a page load, open(catalog.activeWorkspaceId) continues on the layout that was active.

    Returns Promise<WorkspaceCatalog>

  • Delete a saved layout. Deleting the held one leaves the target as it is, holding none.

    Parameters

    • id: string

    Returns Promise<void>

  • Parameters

    • id: string
    • name: string

    Returns Promise<void>

  • Parameters

    • enabled: boolean

    Returns Promise<void>