Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommandation for useGet returned object type/interface #154

Open
barnacker opened this issue Oct 26, 2023 · 0 comments
Open

Recommandation for useGet returned object type/interface #154

barnacker opened this issue Oct 26, 2023 · 0 comments

Comments

@barnacker
Copy link

How would one go about typing the object returned by:
https://feathers-pinia.pages.dev/services/use-get.html#returned-object

I was planning to do something like:

const myStuff: UseGetResult = myService.useGet(id)

And then I would dig as needed depending on the case.

I looked into the code and found that the returned object didnt have an interface such as:

useGet(id: MaybeRef<Id | null>, params?: MaybeRef<UseGetParams>): UseGetResult

But currently is implemented this way:

useGet(id: MaybeRef<Id | null>, params?: MaybeRef<UseGetParams>): {
    params: UseGetParams;
    isSsr: boolean;
    data: SvcModel<Svc> | null;
    ids: Id[];
    getFromStore: any;
    get: () => Promise<AnyData>;
    request: {
        then: <TResult1 = AnyData, TResult2 = never>(onfulfilled?: ((value: AnyData) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined) => Promise<TResult1 | TResult2>;
        catch: <TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined) => Promise<AnyData | TResult>;
        finally: (onfinally?: (() => void) | null | undefined) => Promise<AnyData>;
        readonly [Symbol.toStringTag]: string;
    } | null;
    requestCount: number;
    queryWhen: (_queryWhenFn: () => boolean) => void;
    isPending: boolean;
    hasBeenRequested: boolean;
    hasLoaded: boolean;
    error: any;
    clearError: () => null;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant