Pebble App Framework: Phone API
    Preparing search index...

    Interface FeatureHooks

    The moments in the app's life a feature can act on. Every hook is optional.

    interface FeatureHooks {
        components?: unknown[];
        requests?: string[];
        configOpened?(): void;
        configSaved?(): void;
        message?(payload: Record<string, number | string>): void;
        page?(config: ClayConfigItem[]): ClayConfigItem[];
        ready?(): void;
        refresh?(slow: boolean): void;
        seeded?(
            config: Record<string, unknown>,
            echoed: (name: string) => unknown,
        ): void;
        settingsOut?(dict: AppMessageDict): void;
        settingsUnanswered?(): void;
    }
    Index
    components?: unknown[]

    The Clay components the page hook's rows are drawn with, such as the plugin sources' note. The app registers each one before the page opens when the page holds a row of its type, and takes it off again on an open whose page holds none. A feature that brings them keeps them out of the bundle of any face that never uses the feature.

    requests?: string[]

    The watch's request keys this feature answers, by name, such as WEATHER_REQUEST. The app logs one warning for a request no listed feature answers, which is how a face that declares a feature's keys but never opted into it finds out.

    • The settings page is about to open, while the old settings are still the saved ones.

      Returns void

    • The settings page closed and its new settings are saved.

      Returns void

    • A message arrived from the watch. Each key the face declares can be read by its number, whichever way the phone keyed it.

      Parameters

      • payload: Record<string, number | string>

      Returns void

    • Changes the settings page just before it opens, such as adding a choice only this phone can offer.

      It runs every time the page opens, after configOpened. It gets its own copy of the face's page, or of the page the features before it handed back, and returns the page to open. It can change the copy it is given and hand that back. It keeps nothing from one open to the next, since each open starts again from the face's own page, which the defaults and the settings restore also read. A throw skips this hook alone, and the page opens with what the hooks before it made.

      Parameters

      Returns ClayConfigItem[]

      The settings page to open.

    • PebbleKit JS is ready, and the settings request has gone out.

      Returns void

    • The background refresh ticked. slow is true on the less frequent ticks, the ones meant for data that changes slowly, such as weather.

      Parameters

      • slow: boolean

      Returns void

    • Fixes up the settings the phone just took back from the watch, before they are saved.

      It runs when the phone fills its saved settings from what the watch sends back, such as after the Pebble app is reinstalled. The seed copies each setting the face's own page has a row for. This hook can set one the page has no row for, or put back a value that no longer makes sense on this phone. It changes the settings it is given, and everything it sets is saved. A throw skips this hook alone, and the settings are still saved.

      Parameters

      • config: Record<string, unknown>

        The settings about to be saved, by name. Change them in place.

      • echoed: (name: string) => unknown

        Reads one setting, by name, as the raw value the watch sent back, or undefined when it sent none. Nothing is converted, so a select comes back as the number or the text it was sent as, and a toggle as 0 or 1. The plugin source fields are text, so a hook compares them as text.

      Returns void

    • Changes the settings a save or a restore sends the watch, after the phone has saved them.

      It is for a value the watch has to hold that the feature decides in place of the page, such as the weather's units while a plugin serves them. It changes the dict it is given, keyed by message key number. A throw skips this hook alone, and the settings still go.

      Parameters

      • dict: AppMessageDict

        The settings about to go to the watch. Change them in place.

      Returns void

    • The watch turned away every settings request since the last ready, so no settings reply comes until the next ready asks again.

      Returns void