-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Now, If we want to update a Query
's options, we should wrap the "dynamic options" in an option
function like this:
const query = new MobxQuery({
options: () => ({
enabled: this.myObservableValue > 10,
}),
});
Considering enabled
is one of the mostly used options, we can make it reactive by default like:
const query = new MobxQuery({
enabled: () => this.myObservableValue > 10, // which is a shortcut for `computed(() => this.myObservableValue > 10)`,
});
And queryFn
should be able to be a computed
too. like this:
const id = observable.box(null);
new MobxQuery({
queryFn: computed(() => id.get() ? axios.get(`/api/id/${id.get()}`) : skipToken), // is a shortcut for `{ options: () => ({ queryFn: id.get() ? axios.get('/api/id/${id.get()}') : skipToken })}`, which is not supported now, too
})
All these cases can be found in official vue adapter document(considering vue-reactivity and mobx is almost the same thing, this library and official vue adaptor can share the same use cases and API design and even implementation):
https://tanstack.com/query/v5/docs/framework/vue/guides/disabling-queries
If you think these proposals are acceptable, I can submit a PR maybe this weekend?
Metadata
Metadata
Assignees
Labels
No labels