@gphone/sdk
    Preparing search index...

    Interface CrudOptions<T, TDraft>

    Configuration for createCrudStore — sort order, validation, and the events it uses.

    interface CrudOptions<T, TDraft> {
        service?: string;
        sort?: (a: T, b: T) => number;
        validate?: (draft: T | TDraft) => void;
    }

    Type Parameters

    • T
    • TDraft
    Index
    service?: string

    Reach the server through the generic service route instead of named NUI actions.

    Set it and events become server action names — get, create, update, delete — rather than rows in shared/routes.ts. That is the only path open to an app installed from the Store, which cannot add a route to a table shipping inside gPhone.

    Core services leave it unset and keep their named routes, which routes.test.ts cross-references against the server and the mock — a check worth keeping for the apps that ship in-tree.

    sort?: (a: T, b: T) => number

    One order for the list, however it changed.

    This is what "append vs prepend" was really asking. Notes pushed new rows onto the end, Photos unshifted them onto the front, and Photos sorted on load but not after an add — so a photo taken while the gallery was open sat in the right place only until the next reload. A comparator settles it once for every path.

    validate?: (draft: T | TDraft) => void

    Throw to refuse a write before it leaves the phone. The message reaches the user.

    Runs on both paths, and they do not carry the same shape: add passes a TDraft with no id yet, update passes a whole T. A validator therefore has to accept either — Partial<Contact> is what the one implementation actually takes — which is what the previous any was standing in for.