Subscribe on changes!

avoid toRefs when spread, whether it is feasible

avatar
Aug 17th 2021

What problem does this feature solve?

export default {
  setup() {
    const data = reactive({
      count: 0,
    });
    return { ...toRefs(data) }
  }
};

data is a proxy can we intercept spread operation, auto use toRef for all property, avoid manually toRefs? i don't know whether it is feasible thanks

What does the proposed API look like?

export default {
  setup() {
    const data = reactive({
      count: 0,
    });
    return { ...data }
  }
};
avatar
Aug 17th 2021

No that's not possible. WE would have to parse the JS AST for this, which is not something that would fit into the browser build.

avatar
Aug 17th 2021

No that's not possible. WE would have to parse the JS AST for this, which is not something that would fit into the browser build.

sorry, just use proxy can't Identify which one is spread operation?

avatar
Aug 17th 2021

no