Ideas for namespacing Component IDs?

I’ve come to the conclusion that with the current architecture of Dash there are too many drawbacks with the aforementioned approach.

Namely:

  1. namespacing must be done dynamically (to avoid potential namespace conflicts)
  2. use of Location components is handicapped

For 1. the effect is that there is a drastic increase in page load and update time. For 2. we can only have a single Location component, which forces apps to be tightly coupled to the interface I created.

To resolve both of these issues, I have moved towards an approach that I first saw outlined by @Vlad Multiple Dashboards?. I think for the time being, this is a more practical approach until Dash has native support for multi-page apps.

Creating a single page app now looks like

server = Flask(__name__)

app = Page1(name="home", server=server, url_base_pathname="/")

if __name__ == "__main__":
    server.run(host="0.0.0.0")

Creating a multi-page app (Method 1)

server = Flask(__name__)

index_app = IndexApp(name="home", server=server, url_base_pathname="/")
section_app = Section(name="section", server=server, url_base_pathname="/app1")

if __name__ == "__main__":
    server.run(host="0.0.0.0")

Creating a multi-page app (Method 2)

class MyApp(MultiPageApp):
    def get_routes(self):

        return [
            Route(IndexApp, "index", "/"),
            Route(Section, "home", "/app1")
        ]

server = Flask(__name__)

app = MyApp(name="", server=server, url_base_pathname="")

Code and install details: https://github.com/sjtrny/dash-multi

1 Like