Fork me on GitHub

RAD progress: I got quite a bit of File Upload working in RAD today. It needs a lot of refinement, but it already allows for selecting a file, uploading it sideband while they continue to edit the form, tracking upload progress, and fixing up the form values on save.

🚀 56

Question: why in the live routing example (#37 in developer's guide) do you not need to use an element factory on Main and Settings? I see that they are not composed into a tree in code explicitly so does the router do this behind the scenes?


@looprecur you don’t need to make factories…the router makes its own…just an oversight in book


I have a smart template in my editor that makes a new defsc and factory in code if I just type class name…just forgot to delete the factory.


Okay, thanks!


Is :will-enter a good place to check for an active session, and is this a reasonable way to do it?

{:will-enter (fn [app {:keys [id] :as params}]
               (let [editor-ident [:component/id :editor]
                     session-valid? (get-in (fapp/current-state app) [:component/id :session :session/valid?])]
                 (if session-valid?
                   (dr/route-deferred editor-ident ...)
                   (dr/route-deferred editor-ident
                        (dr/change-route app ["main"])
                        (dr/target-ready! app editor-ident))))))}
It seems like this would need to be done for every route target that needs auth …


Remember that will-enter can be called multiple times during route resolution (search for matching route)


perhaps not the best name…should prob be called “might-enter”


so as long as the code is idempotent in nature it is prob ok


I would tend to put security about session in my own nav-to kind of function. If you want to co-locate data/lambdas related to it on targets, then just add that to the options map of the compinent under new nsed keys


well it’s just doing a read on the global app state … 3 times … maybe it’d be better to check in the URL parser before change-route even gets called the first time …


yeah, I guess if you’re coming from strings it might make sense to use will-enter now that you say that


yeah, the only thing before :will-enter is my pushy URL parse code


Is there a way to look up a component based on the route str vector? dr/route-target? Yes, this works from my URL parser to get the component options and I’ll add an entry to check if it needs auth:

      (comp/registry-key->class :riverdb.ui.root/TopRouter)
      ["sitevisit" "edit" "123"])))


oh no actually that just gets the top level route target …


@tony.kay Is the function delta->datomic-txn supposed to handle Fulcro tempids well, or is that something that might need to be improved, or am I thinking about it the wrong way? I can come up with a specific failing example, just wanted to ask the general question first.


from what I could tell reading that fn a week or two ago is that it only handles tempids that are of the form :entity.type/id and replaces it with UUIDs. This didn’t work for me because I use :db/id for my tempids and must parse and replace with longs.


you talking RAD???


oh right sorry and I’m not using RAD


that is definitely not refined yet. RAD datomic adapter is currently only implemented/tested if you use user-domain UUID for ids…but I do plan on making an option for dealing with plain :db/id as the ID of a thing.


but in the case you’re using the supported ID type, then it does handle tempids. There is more middleware to install…file uploads needs to be able to handle tempids, etc.


Yes I'm talking RAD. The datomic RAD driver is where that function comes from. You give it a forms diff that has before and after. What I give it has (tempid/tempid)-s in it (Fulcro tempids).


(Give it result of fs/dirty-fields).


Yes, but it assumes something like :account/id is a reified field on your entity, not :db/id


that’s the option that needs added to the adapter: something that tells it IDs map to db/id


also, much of RAD currently assumes UUIDs, so there’s some work to do. Most SQL dbs are also going to want to use integer IDs


My personal project uses user-space UUIDs, so those are going to get preferential treatment (from me at least)


I've converted to using uuids (so idents always /id) completely on the client. No :db/id there at all. Wanting to go for the most recommended way always! But I still use tempids as per the recommendation from you and @thosmos as it happens.


The recommendation was for the server to just unwrap them when doing tempid remapping.


RAD uses tempids, so not sure what your prob is


or wait…does that happen one layer above…


might be one layer above if you’re using the low-level fn directly


use the source 🙂


Well that answers my question. I'll look some deeper. Never found that function being called from anywhere when I looked, but that must have been a bad search on my part.


each db adapter defines a handler. That handler in datomic.clj calls that fn


line 170 is the fn, 181 is the call


Thanks, will look..


and yes, that’s where the tempid magic is happening


line 180 transforms the delta to use squuids


Got it: form-delta (sp/transform (sp/walker tempid/tempid?) fulcro-tempid->real-id form-delta)


@thosmos will proposed-new-path work for you?


it returns idents of targets…you could use that as a starting pt to make whet you need


the logic in change-route-relative is what you really want: find the target…could factor that out


I’ll take a crack at factoring out the find algo


There is a TODO in that ns…a lot of that logic is duplicated in two places already I think


and would be nice as a top-level fn…just didn’t want to fiddle with it and break things 😛


yeah I saw that message. if I get something working I’ll maybe see if it works for those


guess I have enough running on it now and tests that I could fully test it and feel comfortable


just looking at the fns: dr/proposed-new-path, dr/signal-router-leaving, and dr/change-route-relative, it appears that the latter 2 call and use variations of the first. So it seems like the first could generate enough metadata on the path to allow the other two to use its output and minimize the duplication?


seems reasonable


I don’t have the brainwidth for this right now