-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dependencies between Dash components #2105
Conversation
I have a dash-component1 that depends on react-lib1. I also have dash-component2, which depends on react-lib1 and dash-component1. Dash-component2 is a plugin to dash-component1. Since ComponentRegistry.registry is an unordered set, the dash components added to it may not be in the order in which they were added to it. I need to load scripts (dash components) in the order in which they were imported.
Thanks @pikhovkin! Just to be sure I understand the situation, you're trying to ensure that the files in Depending on import order feels a bit fragile to me, but I suppose you can have I think this would be better with https://pypi.org/project/ordered-set/ rather than using |
@alexcjohnson thanks for the answer, but you misunderstood. >>> s = set(['h'])
>>> s.add('a')
>>> s
{'a', 'h'}
>>> s.add('g')
>>> s
{'a', 'h', 'g'}
You can use third-party libraries if you like. Although only the |
I understand that, I'm just trying to pin down WHY I would care about that order. Most of the time import order is irrelevant, as is the case for Python and JS imports in general. There are conventions about what order you should put imports at the top of a module, but it's supposed to be just conventions. If the behavior is different when you change that order it would generally be considered a bug. Did I understand correctly that what matters to you is the order the JS scripts are executed on the page? And that (after we make
Right, that's what I meant by "behavior that the Dash core itself doesn't use." What I'm concerned about is other users of Dash that may have found a reason to inspect |
I also think it would be best if this was a proper set. |
The order is important when the plugin should work. The plugin depends on the parent component (a
Have you ever seen an example of someone doing something with |
I am also interested in progress on this PR. As I understand, it would enable people to wrap leaflet plugins as separate Dash components, and use them with |
@alexcjohnson How can I help to speed up merging of this PR? |
@pikhovkin as I said before I'm not aware of any external uses of That being said, there are actually three things Dash depends on this object doing ( The only other thing I can think of is maybe removing items? Like if package A gets pulled in by package B, so A is implicitly added to the registry, but you don't actually want package A (and the extra JS it loads on the page). Then you could imagine wanting to remove A from the registry. Sets have So we could add these methods, or even wait to see if anyone complains and then add them... but to my mind it'd be easier to just use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 Thanks @pikhovkin and @T4rk1n
@T4rk1n please add a changelog entry, then we can merge.
I have a
dash-component1
that depends onreact-lib1
. I also havedash-component2
, which depends onreact-lib1
anddash-component1
.dash-component2
is a plugin todash-component1
.Since
ComponentRegistry.registry
is an unordered set, the Dash components added to it may not be in the order in which they were added to it.I need to load scripts (dash components) in the order in which they were imported.
I suggest a small change in
dash/development/base_component.py