graphery / graphane

Data Visualization Microframework
MIT License
4 stars 0 forks source link

Unpredictable behavior when loading g-load plugin twice #2

Closed petergreendr closed 1 month ago

petergreendr commented 2 months ago

If you run the Load plugin twice by mistake, it produces a strange behavior that is not described correctly.

I have done some tests with other Graphane plugins and they don't seem to have apparent problems if you load them twice.

petergreendr commented 2 months ago

See an example in: https://playground.graphane.dev/editor/gdhofhcf/

pabloalmunia commented 2 months ago

Thanks Peter for the example, I now understand how a plugin is loaded more than once, yoy load several URLs. If you didn't do it this way, the plugin would not load more than once.

The problem has been identified. Directives can be defined more than once, i.e. when a plugin defining a directive is loaded twice, the second time the first directive is not replaced, is added. As a consequence, it is executed twice with unexpected results.

The template engine will be refactored so that the directive registry ensures that there is only one handler for each directive. If a plugin defining a directive is loaded more than once, or to plugins defines the same directive, only the last instance created will be executed.

pabloalmunia commented 1 month ago

We have just released version 1.0.0-beta.2 which fixes this bug.

Now directive handlers are unique, i.e. if you load more than once a plugin that defines a directive, only the last is active. THe plugins can query the handler already installed for the directive and act accordingly during the installation process.

Additionally, we have included the functionality to load external resources without the need for a plugin by:

g-content="$$.fromURL('resource')”

Please, confirm that the error is fixed to close this issue.

petergreendr commented 1 month ago

Umm, here are two things at once.

Yes, I confirm that now if I load the same plugin twice, the behavior is consistent.

But on the other hand, has the load plugin been removed to incorporate it into the component? This is good news, but a bit confusing.

I close the issue...