This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-19
Channels
- # announcements (10)
- # aws (3)
- # aws-lambda (1)
- # babashka (24)
- # beginners (57)
- # boot (5)
- # calva (20)
- # chlorine-clover (3)
- # cider (14)
- # clj-kondo (37)
- # clojars (17)
- # clojure (200)
- # clojure-dev (40)
- # clojure-europe (9)
- # clojure-france (7)
- # clojure-gamedev (5)
- # clojure-hungary (4)
- # clojure-italy (8)
- # clojure-losangeles (2)
- # clojure-nl (9)
- # clojure-uk (97)
- # clojurebridge (1)
- # clojured (3)
- # clojuredesign-podcast (23)
- # clojurescript (13)
- # code-reviews (2)
- # component (22)
- # core-typed (7)
- # cursive (64)
- # datascript (12)
- # datomic (60)
- # emacs (6)
- # fulcro (54)
- # graalvm (11)
- # graphql (3)
- # hoplon (25)
- # jobs (1)
- # joker (85)
- # juxt (5)
- # kaocha (10)
- # klipse (8)
- # malli (2)
- # off-topic (36)
- # parinfer (1)
- # pathom (1)
- # re-frame (9)
- # reagent (4)
- # reitit (1)
- # remote-jobs (1)
- # shadow-cljs (24)
- # spacemacs (1)
- # sql (39)
- # tools-deps (10)
- # tree-sitter (18)
- # xtdb (18)
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.
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.
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
#(do
(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)
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
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/component-options
(:target
(dr/route-target
(comp/registry-key->class :riverdb.ui.root/TopRouter)
["sitevisit" "edit" "123"])))
@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.
This is my version of that fn for using :db/id tempids https://github.com/thosmos/riverdb/blob/e0d96386a2226dce70fe2a8651a46b14f4f56c11/src/server/riverdb/api/mutations.clj#L177
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).
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.
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.
Got it: form-delta (sp/transform (sp/walker tempid/tempid?) fulcro-tempid->real-id form-delta)
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
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?