The preferences interface returned by PlayerClient.getPrefs.

Extends the Gadgets API Prefs surface with existence checks (IPrefs.has) and nullable getters, which let a gadget distinguish an unset preference from one deliberately set to a falsy value such as false, 0, or ''.

interface IPrefs {
    getArray(key: string): string[];
    getArrayOrNull(key: string): null | string[];
    getBool(key: string): boolean;
    getBoolOrNull(key: string): null | boolean;
    getCountry(): string;
    getFloat(key: string): number;
    getFloatOrNull(key: string): null | number;
    getInt(key: string): number;
    getIntOrNull(key: string): null | number;
    getLang(): string;
    getModuleId(): string | number;
    getMsg(key: string): string;
    getString(key: string): string;
    getStringOrNull(key: string): null | string;
    has(key: string): boolean;
    new(): {
        moduleId: string | number;
    };
    set(key: string, val: any): void;
    setArray(key: string, val: any[]): void;
}

Hierarchy (view full)

Methods

  • Parameters

    • key: string

    Returns string[]

  • Returns the preference value, or null if it is not set.

    Parameters

    • key: string

    Returns null | string[]

  • Parameters

    • key: string

    Returns boolean

  • Returns the preference value, or null if it is not set.

    Parameters

    • key: string

    Returns null | boolean

  • Returns string

  • Parameters

    • key: string

    Returns number

  • Returns the preference value, or null if it is not set.

    Parameters

    • key: string

    Returns null | number

  • Parameters

    • key: string

    Returns number

  • Returns the preference value, or null if it is not set.

    Parameters

    • key: string

    Returns null | number

  • Returns string

  • Returns string | number

  • Parameters

    • key: string

    Returns string

  • Parameters

    • key: string

    Returns string

  • Returns the preference value, or null if it is not set.

    Parameters

    • key: string

    Returns null | string

  • Returns true if the preference has been assigned a value.

    Note: the Gadgets API exposes no existence check, so for a preference backed by a real player this is a probe — a preference is considered present when it reads back as a non-empty string. A preference explicitly set to an empty string is therefore reported as absent. Preferences backed by MockPrefs track existence exactly.

    Parameters

    • key: string

    Returns boolean

  • Returns {
        moduleId: string | number;
    }

    • moduleId: string | number
  • Parameters

    • key: string
    • val: any

    Returns void

  • Parameters

    • key: string
    • val: any[]

    Returns void