You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In vue-concurrency I call a function useTask which returns a reactive() object with a bunch of computed() in it. useTask is called in setup() so so far so good.
But task can create a new task instance via task.perform() which creates yet another reactive() and multiple computed(). Sometimes task.perform() is called right away in setup() but sometimes it's called later, maybe after user interaction. In that case vm is null and the fallback solution is used. The fallback solution then creates a performance overhead.
Maybe I should redesign my library not to create new computed for every task.perform(), but so far this solution was really convenient.
If not, maybe you would like to create a formal RFC to for discussion first. This plugin is aim to match with Vue 3's API design, so we will only ship feature that landed to Vue 3.
The process will be
RFC -> Vue 3 implementation -> Merged and released -> @vue/composition-api implementation
If not, maybe you would like to create a formal RFC to for discussion first. This plugin is aim to match with Vue 3's API design, so we will only ship feature that landed to Vue 3.
Yeah, effectScope is nice but I can't find a way how it would solve my issue right now. I need a lower level solution. I'll think about it and I'll create an RFC.
I just read this great article https://antfu.me/posts/async-with-composition-api#explicitly-bound-the-instance from @antfu and I figured it would be really nice if there was a way to pass instance also to
computed
.The
fallback
solution in computed properties that happens wheninstance
is missing is quite costly and so it would be nice to get around this.https://github.com/vuejs/composition-api/blob/master/src/apis/computed.ts#L75
My usecase:
In vue-concurrency I call a function
useTask
which returns areactive()
object with a bunch ofcomputed()
in it.useTask
is called insetup()
so so far so good.But task can create a new task instance via
task.perform()
which creates yet anotherreactive()
and multiplecomputed()
. Sometimestask.perform()
is called right away insetup()
but sometimes it's called later, maybe after user interaction. In that casevm
is null and the fallback solution is used. The fallback solution then creates a performance overhead.Maybe I should redesign my library not to create new
computed
for everytask.perform()
, but so far this solution was really convenient.SInce vue 3 accepts an object as a 2nd param maybe it could be okay to allow
computed(() => {}, { instance });
The text was updated successfully, but these errors were encountered: