fulcro

tony.kay 2025-09-07T14:43:47.393969Z

I’ve decided that the best approach to fixing the routing issues and incompatibility for RAD and statecharts is to move the general concept of a routing system into Fulcro itself, and once that is stable, rewrite RAD to use it. Then a statecharts system could install itself as the routing system, and RAD would “just work”. Commit 3ba4cd0bfc016f1d26feb49e6029dfbcc7ac704b of Fulcro contains this (alpha quality) code, along with a browser URL integration system for dynamic routing (i.e. you can install URL integration with dynamic routing with a single function call now, as long as you port your UI calls for routing to the new protocol). This is the implementation for dynamic routing (with ns docstrings): https://github.com/fulcrologic/fulcro/blob/3ba4cd0bfc016f1d26feb49e6029dfbcc7ac704b/src/main/com/fulcrologic/fulcro/routing/dynamic_routing_browser_system.cljc This file is a sample application that uses it: https://github.com/fulcrologic/fulcro/blob/3ba4cd0bfc016f1d26feb49e6029dfbcc7ac704b/src/todomvc/fulcro/routing/dynamic_browser.cljc Notice that the only real difference at the application level is: 1. Installing the routing system on the app 2. Using the routing system API calls instead of things like dr/change-route! One additional important note: The dynamic routing namespace is actually more flexible than a URL can handle (you can have sibling routers, and therefore could have more than one target on-screen at a time, with no way to encode that as a single URL). So, to avoid bugs you must not create apps that have parallel live routes if you want to leverage a routing system that has URL integration (routing systems need not HAVE URL integration).

👀 1
tony.kay 2025-09-07T14:45:17.519569Z

I’m open to feedback/contributions on: • The protocol. Did I cover what we need? • Support for hash-based URLs and prefix (partially written/in progress) • Bug reports/other suggestions/help

tony.kay 2025-09-07T14:48:50.114329Z

Ah, and I have not fully baked pasting in URLs yet…in other words initializing the route…there’s some integration for auth that needs to be possible there, without embedding it in the system. Perhaps that is your responsibility. For a dynamic routing system you can do your application initialization, read the URL, and decide what to do (cache the URL, send to login, restore url)…all of that is code that you CAN write with the implementation as it exists.

tony.kay 2025-09-07T14:51:31.791519Z

For a statecharts routing system, that overall logic would go in the statechart itself, and the chart will treat the current route as an active state that is enforced. An incoming URL will be event data on initialization that can flow though chart logic.