Fork me on GitHub

Is anyone doing type testing for fulcro? I'd like to render a component and check that a load has been triggered for example


hi! i wonder whether there’s a way to invoke df/load! with not-yet-mounted app. i use app/set-root! before the load, but it seems like the load tx forces re-render and crashes

Jakub Holý (HolyJak)16:04:13

@tony.kay According to the body of a defrouter is only executed if current-state is one of #{:initial :pending :failed} but in practice it is also executed if it is nil . I guess the docs either need to be corrected or something somewhere fails to set the state correctly to :initial . (This is in a body of a child router when I have routed to a target of a prent router.)


@holyjak it will only get nil if you have not set initial state and initialized the routing system before mounting…but you’re right, it’d be fine to tolerate nil

Jakub Holý (HolyJak)17:04:36

Hm, I think I have done that... Let me look more into it


@fjolne.yngling bug. that is supposed to be fine, and renders should be ignored if nothing is mounted. which renderer? stack trace? pls open issue.


is there a shorthand method for resetting a component to its initial state?


i dont think so


yeah, seems like the easiest way is to just map over the component’s initial state and call set-value! with each kv


well, if your initial state actually includes all keys, then (merge/merge-component this ThisClass (comp/get-initial-state ThisClass {})) should do it (check args…not looking at docs)


well, and you’d have to make sure to pass in the ID correctly to get-initial-state


if it has a non-constant ident


and that does the entire sub-tree, of course


Then there’s form-state, which is meant to handle this exact case…it has a reset pristine->entity helper to roll back to that last checkpoint


and can be told exactly what to track


that all makes sense, thanks for the response. feels a little funky to shoehorn the form state into something like a top-level view that’s navigated away from (my case here), but that is interesting


How difficult would it be in fulcro to push 2MB binary buffers (js/ArrayBuffers) from server to remotes? The dev guide discusses (sections 9.4 -- 9.5) getting binary data with http-remote, but I could not find much in the guide or code about pushing binary data with fulcro-websocket.


@iradavidhale See RAD file upload code…also beware that websockets are not ideal for pushing large binary data…use two remotes: one for HTTP uploads, and one for your websockets. HTTP is well-designed for pushing binary up


(browsers change continuously…I don’t think the websocket spec prohibits it, but I used to hit all sorts of problems trying it)


so, short answer: fulcro websockets make no provision for it


You could try just sending it in a transit-supported Uint8Array:


as in: encoded that was as a mutation parameter (transact! this [(upload {:file buffer})])


where upload might get the proper raw bytes in :file parameter on server….have not tried it


See js docs for turning your ArrayBuffer into Uint8Array


Thanks! I am a fulcro (and full-stack) beginner, so this is super helpful. I have multiple clients that will all need the same binary data ASAP, which is what made me think of websockets. By "two remotes" I think you are suggesting that (1) the server uses a websocket to tell each client that they need a new buffer, and then (2) they use http to request their buffer. Is that your suggestion?


that’s how I would do it. I’ve done something like this with server generated EDN endpoints and the clients then did a regular http call to get it. In my case I was able to cache the EDN as a file and use regular file-serving of Nginx to serve it.


Thanks also for the pointer to transit-js bytes. I was looking at transit-cljs and transit-clj (no byte buffers), but should have been looking at transit-js and transit-java. Interop!


@iradavidhale So, I’m suggesting that when there is a file to upload you push it via a POST. Fulcro’s file upload support basically can do the lifting for you by encoding both the mutation and the file in one request (see book). With websockets (and http remotes) you can possibly leverage the fact that we’re using transit to just send byte arrays back and forth as parameters…if transit can do it, Fulcro should work with it.


@tony.kay Sorry for the confusion. I think I mis-used "remotes" in my original question. I want to spontaneously (in real time) push big buffers the other way, from to This is the key to the app; the other stuff seems easy to do with fulcro.


oh, well, just try it…your push received will just get the decoded EDN via transit, so you should just end up with buffers


@tony.kay, sorry about that, I didn’t know to discuss problems here. Re issues with the logic, I’m using the template, I’ve made no login changes whatsoever other than changing the remote to ws-remote


is the template still working right with regular rmotes? I’ve not checked it in a very long time…perhaps there was a regression or something…pls try the unmodified template


the remote itself should not affect anything if you’ve plugged it in right…should be completely transparent


See todomvc example in main Fulcro Repo..I’ve got that set up so I can switch back and forth


I’ve been watching your videos to try and unpick what’s happening. The template does appear to work with the regular remote. I’ll try cloning it from scratch


they are not feature-rich, but you can see the clear difference is in middleware


I’ve documented in the issue the specific additions I made as the websockets lib readme uses immutant, not http-kit as the template uses.


Thanks, will read and test =)…


I use immutant on a project…works fine. You changed the sente adapter, right?


The websockets themselves appear to work, as I got signup to work


It’s just login that appears to fail


weird…that uses a mutation return value


wonder if something is wrong in that plumbing


I’m not setting the csrf token, but I figured that wasn’t the issue as signup works…


so, for return values to work right, Fulcro has to send a mutation join that includes [*] as the subquery…I think older versions of Fulcro might have missed that?


vague memories…


The real question is: Did the new session data merge into app state?


you could put your broken websocket version on GH and send a link


Sure, 2 secs


@tony.kay if i recall correctly older versions of fulcro automatically included [*] as a mutation join if you didn’t include a query in the mutation join


Just to be clear, older versions are the non-rad version?


as they were built before RAD existed yes


but Im not sure what is the minimum version of fulcro required for rad to work


So is the template version deprecated?


@folcon not deprecated…just guessing why you might have issue. template might be defaulting to a version that had a bug? RAD requires latest (SNAPSHOT requires latest SNAPSHOT in some cases)


I’ve forked it with just the websocket changes:


I’m bumping various versions just to start


I thought you said immutant?


The readme on fulcro-websockets uses immutant, the default template uses http-kit, I swapped immutant -> http-kit to be in line with the template.


It is working fine for me


using Fulcro 3.2.0 and latest pathom


I signed up with , and then logged in as that user.


This template could sure use some love


it’s kind of crappy 😜


What deps are you using? (you mentioned you bumped them)


diff --git a/deps.edn b/deps.edn
index 9bc7a3a..acace49 100644
--- a/deps.edn
+++ b/deps.edn
@@ -5,8 +5,8 @@
            bk/ring-gzip                        {:mvn/version "0.3.0"}
            com.taoensso/timbre                 {:mvn/version "4.10.0"}
            com.taoensso/tufte                  {:mvn/version "2.1.0"}
-           com.wsscode/pathom                  {:mvn/version "2.2.27"}
-           com.fulcrologic/fulcro              {:mvn/version "3.0.12"}
+           com.wsscode/pathom                  {:mvn/version "2.2.31"}
+           com.fulcrologic/fulcro              {:mvn/version "3.2.0"}
            com.fulcrologic/fulcro-garden-css   {:mvn/version "3.0.7"}
            com.fulcrologic/semantic-ui-wrapper {:mvn/version "1.0.0"}
            com.fulcrologic/guardrails          {:mvn/version "0.0.9"}
@@ -25,7 +25,7 @@
  :aliases {:clj-tests {:extra-paths ["src/test"]
                        :main-opts   ["-m" "kaocha.runner"]
-                       :extra-deps  {lambdaisland/kaocha {:mvn/version "0.0-554"}}}
+                       :extra-deps  {lambdaisland/kaocha {:mvn/version "1.0-612"}}}
            ;; See  for Emacs support
            :dev       {:extra-paths ["src/test" "src/dev" "src/workspaces"]
@@ -34,7 +34,7 @@
                        :extra-deps  {org.clojure/clojurescript   {:mvn/version "1.10.597"}
                                      thheller/shadow-cljs        {:mvn/version "2.8.80"}
                                      expound                     {:mvn/version "0.8.1"}
-                                     fulcrologic/fulcro-spec     {:mvn/version "3.1.4"}
-                                     binaryage/devtools          {:mvn/version "0.9.11"}
+                                     fulcrologic/fulcro-spec     {:mvn/version "3.1.5"}
+                                     binaryage/devtools          {:mvn/version "1.0.0"}
                                      com.github.awkay/workspaces {:mvn/version "1.0.0-RC2"},
                                      org.clojure/tools.namespace {:mvn/version "1.0.0"}}}}}


Btw, this is a fantastic set of tools!

👍 8