react-packages icon indicating copy to clipboard operation
react-packages copied to clipboard

Idea: hooks for Meteor.call

Open ivklgn opened this issue 1 year ago • 3 comments

any ideas for Meteor.callAsync and react hooks?

ivklgn avatar Aug 15 '24 05:08 ivklgn

What are you thinking about? What would be the benefit and how would it look like?

Maybe something like this:

const [result, error] = useCallAsync('method.name', param1, param2, ...)

The problem with this one is that the method would get called immediately or are we looking for different options along the lines of Apollo Mutations? https://www.apollographql.com/docs/react/data/mutations

StorytellerCZ avatar Sep 08 '24 09:09 StorytellerCZ

yes, something like that we can make 2 hooks

  • useCallAsync
  • useCallAsyncLazy (https://www.apollographql.com/docs/react/data/mutations)

but for calls - only one lazy will better!


one more question about type inference for method name and args. do you have ideas about that?

ivklgn avatar Sep 19 '24 17:09 ivklgn

Now that React 19 is out we should look at the new hooks and see what we can adapt for this.

StorytellerCZ avatar Dec 09 '24 05:12 StorytellerCZ