This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-07
Channels
- # announcements (1)
- # babashka (77)
- # beginners (219)
- # chlorine-clover (6)
- # cider (52)
- # clj-kondo (14)
- # cljdoc (5)
- # clojure (173)
- # clojure-europe (49)
- # clojure-finland (1)
- # clojure-germany (2)
- # clojure-italy (1)
- # clojure-nl (39)
- # clojure-sweden (4)
- # clojure-uk (51)
- # clojurescript (25)
- # code-reviews (9)
- # conjure (25)
- # data-science (2)
- # figwheel-main (6)
- # fulcro (74)
- # graalvm (1)
- # graphql (11)
- # jobs-discuss (17)
- # keechma (4)
- # lein-figwheel (4)
- # leiningen (1)
- # luminus (10)
- # malli (14)
- # mid-cities-meetup (2)
- # off-topic (28)
- # re-frame (5)
- # reagent (76)
- # reitit (30)
- # ring (7)
- # ring-swagger (1)
- # shadow-cljs (163)
- # spacemacs (11)
- # specter (2)
- # sql (43)
- # tools-deps (13)
- # vim (6)
- # yada (1)
Is anyone doing https://enzymejs.github.io/enzyme/ 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
@tony.kay According to https://github.com/fulcrologic/fulcro/blob/develop/src/main/com/fulcrologic/fulcro/routing/dynamic_routing.cljc#L794 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
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.
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)
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
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)
You could try just sending it in a transit-supported Uint8Array: https://github.com/cognitect/transit-js
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
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 http://server.cl to http://clients.cl. 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
https://github.com/fulcrologic/fulcro/blob/develop/src/todomvc/fulcro_todomvc/server.clj
https://github.com/fulcrologic/fulcro/blob/develop/src/todomvc/fulcro_todomvc/websocket_server.clj
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.
client just has a commented form on https://github.com/fulcrologic/fulcro/blob/develop/src/todomvc/fulcro_todomvc/main.cljs line 12
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?
@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
as they were built before RAD existed yes
but Im not sure what is the minimum version of fulcro required for rad to work
@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: https://github.com/folcon/fulcro-template
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.
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"}}}}}
~