Iām making a plugin that creates a panel view. Since I canāt easily pass data to the pluginās front end, I have to fetch the necessary data and then initialize the plugin. However, nothing happens. I get a blank panel page. Hereās what I do:
If I move the registration out of the timeout, the panel loads, the plugin loads, and everything works as expected. Why am I unable to register the plugin asynchronously?
How do I initialize my plugin only after the necessary data for it is available?
Yep, thatās what I would do too. But I have a Vuex store attached to my root component and its state depends on the initial data. If I initialize the store state after itās created, I get a bunch of errors from its getters. Therefore, I wanted to initialize the whole plugin app after that data is present.
The real question is why canāt Kirby handle the plugin being initialized asynchronously.
Ok, I think i probably know what happens: panel.plugin() basically only does some transformations and then stores all of it to an object in window.panel. Once the Panel gets loaded, it looks for this objects and actually registers the components etc. in its Vue instance (this way we can bridge between the Panelās Vue isntance and plugins).
Now your call probably takes so long (not saying that its slow, just longer than the rest of the code), that the Panel has already checked and registered everything before your plugin calls panel.plugin().
I donāt see an easy way around this at the moment.
Those panel views are never created. The code works if i move it out of the promise but yeah that doesnāt help me.
Is there any other way register panel plugins dynamicaly or pass them data upfront?