nanostores / query

⚡️ Powerful data fetching library for Nano Stores. TS/JS. Framework agnostic.
MIT License
229 stars 10 forks source link

Allows Consumer Pass Argument for Return Type of `createMutatorStore` #29

Closed martinmckenna closed 9 months ago

martinmckenna commented 9 months ago

Description

Allows consuming code to pass a type argument for the return value of createMutatorStore. Really, it just re-uses the Response argument and passes it through to MutatorCb

Usage

const doThing = async (): Promise<{id: string}> => {
  const r = await fetch("/hello/world");
  return r.json();
};

const $createThing = createMutatorStore<
  { hello: "world" },
  { id: string; description: string }
>(() => doThing()); // will correctly error b/c doThing() is missing `description`
Screenshot 2024-02-05 at 5 07 45 PM
dkzlv commented 9 months ago

@martinmckenna Thanks! Published in 0.2.10.