-
Notifications
You must be signed in to change notification settings - Fork 39
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
Multi-Page Apps - find a better way to build dash.page_registry #76
Comments
Here is a potential solution as outlined by @ chriddyp Have page_registry values return a function that returns the value. So instead of:
it’d be:
meaning:
where
I suspect you’ll be able to do it here: and here: |
It looks like the above solution may not be ideal: For example, let's say you would like to create a "topics" sub-menu from within the In the proposed solution, the for page in dash.page_registry.values()
if page["path"].startswith("/topic") But if you use the value of the function, then we are back to the same issue. The dash.page_registry is not finished building yet, so the sub-menu will not be complete. for page in dash.page_registry.values()
if page["path"]().startswith("/topic") @chriddyp do you have any other comments or suggestions? |
For reference, a note I wrote in a DM with @AnnMarieW - the upshot is I don't think we need to worry about this right now but we could consider adding another mechanism in the future if it becomes a big point of friction.
|
Currently app pages are added to the
dash.page_registry
whendash.register_page
is called. This happens as modules are loaded from thepages/
folder before the app starts. If you try to usedash.page_registry
in an app in thepages/
folder, you must use it in a function, otherwise the page registry may not be complete.Need to find a better way to build dash.page_registry so it's not necessary for people to use a function when trying to use it from within the pages/ folder.
See community discussion here
Description of the workaround here
The text was updated successfully, but these errors were encountered: