Drawflow icon indicating copy to clipboard operation
Drawflow copied to clipboard

How can I use a different drawflow parent other than app in vue3

Open longtengz opened this issue 1 year ago • 3 comments

Hi, I'm trying to upgrade our app from vue2 to vue3. In vue2, we can set drawflow's parent to whatever component we feed it through the last parameter of the constructor. But in vue3, it seems from we can only give appContext as parent.

This troubles us because we're trying to use provide and inject so drawflow nodes can have reactive data changed elsewhere in the app. Now since the parent can only be app, provide and inject no longer works in our setting.

Is there a way we can set a different parent in vue3 other than appContext

Thanks for for this amazing library. I hope to contribute to it but I don't know much about vue's internals to make a PR here.

longtengz avatar Jul 11 '23 07:07 longtengz

You can see in the vue3 example. How do we pass the property df.

  • https://github.com/jerosoler/drawflow-vue3-example/blob/dbd08ca8156a4aae7a8c5d4f9fe5f29a0f5b0a58/src/components/drawflow.vue#L82C8-L82C8

To access from the nodes.

  • https://github.com/jerosoler/drawflow-vue3-example/blob/dbd08ca8156a4aae7a8c5d4f9fe5f29a0f5b0a58/src/components/nodes/node2.vue#L56C7-L56C7

I don't know if this will help you.

jerosoler avatar Jul 11 '23 08:07 jerosoler

Besides using globalProperties, do you see another way to make it work? We have a bunch of provides and injects so it's not very ideal to use globalProperties and also it's not recommended in Vue.

Thanks for your prompt reply.

longtengz avatar Jul 11 '23 08:07 longtengz

🤔 Creating standalone apps? With "createApp"?

jerosoler avatar Jul 11 '23 10:07 jerosoler