Interface ApplicationState<T>

interface ApplicationState<T> {
    get(extra?): ApplicationStateData;
    getSave(options): ApplicationStateData;
    remove(options): ApplicationStateData;
    restore(params): ApplicationStateData | Promise<ApplicationStateData>;
    save(options): ApplicationStateData;
    set(data, opts?): T | Promise<T>;
}

Type Parameters

  • T

    Provides the ability the save / restore 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.

Methods

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

    Parameters

    • Optional extra: object

      Extra data to add to application state.

    Returns ApplicationStateData

    Passed in object with current application state.

  • Returns any stored save state by name.

    Parameters

    • options: {
          name: string;
      }

      Options.

      • name: string

        Saved data set name.

    Returns ApplicationStateData

    The saved data set.

  • Removes and returns any application state by name.

    Parameters

    • options: {
          name: string;
      }

      Options.

      • name: string

        Name to remove and retrieve.

    Returns ApplicationStateData

    Saved application data.

  • Restores a saved application state returning the data. Several optional parameters are available to control whether the restore action occurs silently (no store / inline styles updates), animates to the stored data, or simply sets the stored data. Restoring via AnimationAPI.to allows specification of the duration, easing, and interpolate functions along with configuring a Promise to be returned if awaiting the end of the animation.

    Parameters

    • params: {
          animateTo?: boolean;
          async?: boolean;
          duration?: number;
          ease?: Function;
          interpolate?: Function;
          name: string;
          remove?: boolean;
      }

      Parameters

      • Optional animateTo?: boolean

        Animate to restore data.

      • Optional async?: boolean

        If animating return a Promise that resolves with any saved data.

      • Optional duration?: number

        Duration in seconds.

      • Optional ease?: Function

        Easing function.

      • Optional interpolate?: Function

        Interpolation function.

      • name: string

        Saved data set name.

      • Optional remove?: boolean

        Remove data set.

    Returns ApplicationStateData | Promise<ApplicationStateData>

    Saved application data.

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

    Parameters

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

      Options.

      • Optional extra?: any[]

        Extra data to add to saved data.

      • name: string

        name to index this saved data.

    Returns ApplicationStateData

    Current application data

  • Restores a saved application state returning the data. Several optional parameters are available to control whether the restore action occurs silently (no store / inline styles updates), animates to the stored data, or simply sets the stored data. Restoring via AnimationAPI.to allows specification of the duration, easing, and interpolate functions along with configuring a Promise to be returned if awaiting the end of the animation.

    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.

    • Optional opts: {
          animateTo?: boolean;
          async?: boolean;
          duration?: number;
          ease?: Function;
          interpolate?: Function;
      }

      Optional parameters

      • Optional animateTo?: boolean

        Animate to restore data.

      • Optional async?: boolean

        If animating return a Promise that resolves with any saved data.

      • Optional duration?: number

        Duration in seconds.

      • Optional ease?: Function

        Easing function.

      • Optional interpolate?: Function

        Interpolation function.

    Returns T | Promise<T>

    When synchronous the application or Promise when animating resolving with application.