VulcanJS / vulcan-npm

The full-stack JavaScript App Framework
https://vulcan-docs.vercel.app
MIT License
30 stars 8 forks source link

Create hooks creator "makeUseMulti" #87

Open eric-burel opened 2 years ago

eric-burel commented 2 years ago

Is your feature request related to a problem? Please describe.

When creating a model, you might want to expose reusable hooks with default options:

const useMultiTweets = () => useMulti({model: Tweets})

It is difficult to write such a closure however, because of the parameters structure.

Describe the solution you'd like

const useMultiTweets = makeUseMulti<TweetType>({model: Tweets})

In this example, makeUseMulti handles the merge of paremeters, so that useMultiTweets has the exact same APi as useMulti, but uses Tweets as the default model.

Of course, do the same for other hooks.