fulcro

Yaw Odame 2024-10-03T15:16:02.298289Z

Is there a way for a child route to inherit the parent route param? Example - I want to keep the :profile-id route param while routing from /profile/123 to /profile/123/settings without having to set it for each child route with (routing/route-to! this ProfileSettings {:profile-id 123}) .

Jakub Holý (HolyJak) 2024-10-13T07:44:21.906599Z

Wait with that… 😅

tony.kay 2024-10-13T13:56:14.732149Z

Let me know if you want help or to pair a bit

Yaw Odame 2024-10-13T14:07:32.657779Z

I’m interesting in contributing. Could I join if possible? I’ll have some time later this afternoon (central time)

tony.kay 2024-10-13T14:58:20.382079Z

Let’s see what @holyjak says…time zone coordination can be hard, but I might be able to do that. Today is going to be a good weather day, so I might opt to be outside instead. But yes, you’d be welcome, of course! We just need to coordinate. You two are free to pair up. In general we use Tuple for pairing (which @holyjak actually turned me onto). You don’t need a license for it, as both of us have a license and we can invite guests.

✅ 1
Jakub Holý (HolyJak) 2024-10-13T17:00:11.614289Z

I'm sorry, I can't today

Jakub Holý (HolyJak) 2024-10-13T17:01:21.291219Z

Tomorrow though may be possible, around 8-10pm UTC...

tony.kay 2024-10-13T17:42:02.954699Z

yeah, that’s 1pm my time. I can do that.

Jakub Holý (HolyJak) 2024-10-13T18:30:50.284489Z

Awesome! I have sent you a calendar event. @yaw556, send me your email if you want to join. I’ve stopped paying for Tuple, so if you still have it, you’d need to invite me as a guest 🙏

tony.kay 2024-10-13T18:39:37.114379Z

Yes, I have a OSS tuple license. You both can PM me the tuple email address

🆒 1
Yaw Odame 2024-10-13T19:13:51.500049Z

Perfect. I should be able to join 🤞🏿

Yaw Odame 2024-10-04T14:03:00.230589Z

I am certainly on that dark design path. Keeping the entity id (selected account id or profile id) in the app state and out of the URL path would be cleaner. However, it limits deep linking. I have an account router with child components that query on a specified account id for data related to the account. What’s a good pattern for initializing the fulcro app state with or without an account id in hand? • local storage - seed the app state with the id from local storage • route param (`?rp`) - this was the path I was on. But the params are reset when navigating between screens. Thus requiring me to set the account id each time I call route-to!. I suppose the main account route component could set the id in the app state on will enter, allowing child route components to query it as needed. As a fallback, redirect to accounts list route if the account id is not present in the route param or app state. Would you put that logic in the will-enter?

tony.kay 2024-10-04T14:59:09.951039Z

If you really want deep linking from URLs where a page can be bookmarked then you have no choice but to include it in the URL, of course, and using the route params seems a reasonable course. You have a number of options, but since it is a global concern, I would tend to place that code in some global wrapper, and not in each component. E.g. you could make a URL that always has the account ID in it, but DOESN’T go to Fulcro’s dynamic routing code. I.e. you split the URL, drop the account ID (but put it in app state at the right place) and then send the rest of the URL to route-to! (this would be on startup from a URL) and you make your own HTML5 history plugin that always writes the URLs with the account id from state into the URL, etc. Basically try to model this concern globally. There’s nothing in DR that says you have to even use a URL with it, so writing your own outer layer for interfacing with the URL itself for tracking some important app state is where I’d put it.

👀 1
tony.kay 2024-10-04T15:05:13.686219Z

In other words: I’m not claiming that dynamic routing is a fix-all for every use-case. The mere idea, as I’ve said, that routing should be so tightly coupled with your UI has never set well with me, but many many people like doing it that way. YMMV. I’m more and more leaning towards writing a state chart, and having it do routing based on enter/leave states. Then the global application logic can be properly modeled and not peppered into the UI so much. I’ve been toying with co-locating invocable state charts on components, and using a global state chart as the overall routing tool in my own work, but I’ve not gotten it refined enough to release as a library or template.

👀 1
❤️ 1
Jakub Holý (HolyJak) 2024-10-10T21:07:01.594219Z

Ah, sorry, I completely forgot about this 😢

tony.kay 2024-10-10T23:42:32.760379Z

I may give up on porting it to F3…if you wanted to take a shot at porting just the background job, I did find some tips for that…any interest in that? The first tip I found was this: https://github.com/thheller/chrome-ext-v3 and I think all that needs to happen is to change the shadow build config, fix up the manifest, and rewrite the background job to work as a service worker…not sure what kind of code changes are needed there.

tony.kay 2024-10-10T23:42:54.680519Z

but hopefully just a few on the chrome wrappings

tony.kay 2024-10-03T15:43:32.633619Z

That would not be very good composition for a child to be dependent on a parent. Also remember that routing is often done in a relative manner, and there may be NO URL (e.g. in a mobile native app). Thus, what you are really after is application state that remembers you’re in some sub-section of your application. Dynamic routing is not intended to solve this use-case for you, and the URL integration should be thought of as an “external” concern that is orthogonal (but somewhat compatible) with the routing system (which is more about dynamic query management and UI targeting). What you need to do is find a place in your app state where you store the “current profile” as a fact of the current application state, and then query for that in any component that needs it. This also has the advantage of not requiring the parent to be involved, and improves compositional behavior. This means you need to define a clear lifecycle around that fact (when does it get set, when does it get cleared, etc.). Thus, defining a UI State Machine or State Chart for that part of your application (and getting this logic OUT of the view layer) would be my recommendation. I was always a bit resistant to even adding the dynamic routing features as they exist (the will enter hooks etc) because they sort of encourage this kind of bad composition, but are also quite convenient for many other things. So, I’ve leaned on the side of convenience in those APIs, but it does lead people (including me) down some dark design paths.

❤️ 1
tony.kay 2024-10-09T10:57:35.434699Z

Thanks for the offer. I ended a few hours of work on it last night, most of which was just porting old code to new versions. I think the primary thing is switching the background job to a service worker. But I think I found an example of that

Jakub Holý (HolyJak) 2024-10-14T19:02:06.938589Z

FYI I am in the meeting, hope joining works…

Yaw Odame 2024-10-14T19:03:34.697639Z

Still wait on my tuple email confirmation...

Jakub Holý (HolyJak) 2024-10-14T19:04:21.760389Z

What kind of confirmation? Were you not able to finish setting up your account or what? Anything I can do?

Yaw Odame 2024-10-14T19:07:12.369349Z

Almost got it

Jakub Holý (HolyJak) 2024-10-14T21:38:17.355279Z

I had to go, my WIP PR is https://github.com/fulcrologic/fulcro-inspect/pull/104 Replacing the unsupported and discouraged whitespace w/ simple got rid of the goog problems, now it is Fulcro failing with > Uncaught #error {:message “Invalid join, {:fulcro.inspect.ui.inspector/element nil}“, :data {:type :error/invalid-join}}

👀 1
tony.kay 2024-10-14T22:16:39.861379Z

Perfect! I think that may get it to the point that I can finish the port.

tony.kay 2024-10-14T22:16:54.234399Z

thanks! I’ll see if I can get back to it sometime later today

Jakub Holý (HolyJak) 2024-10-15T06:31:34.392719Z

It is confusing to have 2 threads of communication, I suggest we move to the DM group chat.

Jakub Holý (HolyJak) 2024-10-12T21:42:36.323809Z

I can try to make some time during the week and give it a shot…

tony.kay 2024-10-13T02:09:31.623869Z

thanks!

Yaw Odame 2024-10-08T04:27:54.118049Z

I went the state machine route....way better. Cheers! thanks3 Would be nice to get something like https://statecharts.io/inspect in the fulcro inspect someday.

tony.kay 2024-10-08T13:32:51.198769Z

I would agree.

tony.kay 2024-10-09T03:11:43.676109Z

aaannnnd you just reminded me that I need to fix inspect in the chrome store or they’re going to stop allowing it to work 😞

Yaw Odame 2024-10-09T03:46:30.406249Z

Ha! Let me know if I can help out with that. I am not extremely familiar with Chrome extension dev nowadays, but I could brush up on things.