Provides the ability the save / restore / serialize application state for positional and UI state such as minimized status.

You can restore a saved state with animation; please see the options of ApplicationState.restore.

interface ApplicationState {
    clear(): void;
    current(extra?: object): ApplicationStateData;
    get(options: {
        name: string;
    }): ApplicationStateData;
    keys(): IterableIterator<string, any, any>;
    remove(options: {
        name: string;
    }): ApplicationStateData;
    restore(options: {
        animateTo?: boolean;
        duration?: number;
        ease?: EasingReference;
        name: string;
        remove?: boolean;
    }): ApplicationStateData;
    save(options: {
        extra?: any[];
        name: string;
    }): ApplicationStateData;
    set(data: ApplicationStateData, options?: {
        animateTo?: boolean;
        async?: boolean;
        duration?: number;
        ease?: EasingReference;
    }): void;
}

Methods

  • Clears all saved application state.

    Returns void

  • Returns current application state along with any extra data passed into method.

    Parameters

    • Optionalextra: object

      Extra data to add to application state.

    Returns ApplicationStateData

    Passed in object with current application state.

  • Gets any saved application state by name.

    Parameters

    • options: {
          name: string;
      }

      Options.

      • name: string

        Saved data set name.

    Returns ApplicationStateData

    Any saved application state.

  • Removes and returns any saved application state by name.

    Parameters

    • options: {
          name: string;
      }

      Options.

      • name: string

        Name to remove and retrieve.

    Returns ApplicationStateData

    Any saved application state.

  • Restores a previously saved application state by name returning the data. Several optional parameters are available to animate / tween to the new state. When animateTo is true an animation is scheduled via AnimationAPI.to and the duration and easing name or function may be specified.

    Parameters

    • options: {
          animateTo?: boolean;
          duration?: number;
          ease?: EasingReference;
          name: string;
          remove?: boolean;
      }

      Parameters

      • OptionalanimateTo?: boolean

        Animate to restore data.

      • Optionalduration?: number

        Duration in seconds.

      • Optionalease?: EasingReference

        Easing function name or function.

      • name: string

        Saved data set name.

      • Optionalremove?: boolean

        Remove data set.

    Returns ApplicationStateData

    Any saved application state.

  • Saves current application state with the opportunity to add extra data to the saved state.

    Parameters

    • options: {
          extra?: any[];
          name: string;
      }

      Options.

      • Optionalextra?: any[]

        Extra data to add to saved state.

      • name: string

        Name to index this saved state.

    Returns ApplicationStateData

    Current saved application state.

  • Sets application state from the given ApplicationStateData instance. Several optional parameters are available to animate / tween to the new state. When animateTo is true an animation is scheduled via AnimationAPI.to and the duration and easing name or function may be specified.

    Note: If serializing application state any minimized apps will use the before minimized state on initial render of the app as it is currently not possible to render apps with Foundry VTT core API in the minimized state.

    Parameters

    • data: ApplicationStateData

      Saved data set name.

    • Optionaloptions: {
          animateTo?: boolean;
          async?: boolean;
          duration?: number;
          ease?: EasingReference;
      }

      Optional parameters

      • OptionalanimateTo?: boolean

        Animate to restore data.

      • Optionalasync?: boolean
      • Optionalduration?: number

        Duration in seconds.

      • Optionalease?: EasingReference

        Easing function.

    Returns void