This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-07
Channels
- # announcements (4)
- # babashka (20)
- # beginners (167)
- # calva (1)
- # cider (18)
- # circleci (10)
- # clara (45)
- # clojure (85)
- # clojure-argentina (1)
- # clojure-europe (3)
- # clojure-finland (3)
- # clojure-greece (2)
- # clojure-italy (9)
- # clojure-nl (30)
- # clojure-spec (32)
- # clojure-survey (39)
- # clojure-uk (72)
- # clojurescript (12)
- # core-async (4)
- # data-science (3)
- # emacs (10)
- # figwheel-main (9)
- # fulcro (44)
- # graalvm (3)
- # jobs (12)
- # jobs-discuss (6)
- # joker (3)
- # juxt (1)
- # leiningen (4)
- # off-topic (23)
- # planck (5)
- # re-frame (4)
- # reitit (2)
- # remote-jobs (1)
- # shadow-cljs (43)
- # spacemacs (8)
- # test-check (19)
- # tools-deps (21)
@jarvinenemil SSR does work, but the old template branch probably isn’t up-to-date. I think the basics are covered in the book…really isn’t much more to it than the dom-server macros can be used in CLJ-land to generate strings…you just need to pass the correct props tree to the root. Generating the props isn’t so hard, since you can write all logic in CLJC, and use the same code you used on the client to generate props on the server…there are a few helper functions that can build a db for you on the server based on component initial state, which is the most common case for an initial render; however, if you’re trying to implement SSR that shows some HTML5 routed link, then you might find that you’ve got a bit more work to do. The good news is that Fulcro will run headless in the JVM, so you can create a client with a loopback remote and essentially move it through states until you have what you want.
I do not consider headless Fulcro to be battle-hardened. I do not personally use it that way, and don’t know if anyone else in the community does. I have seen no bug reports, but that means very little, really.
The DOM stuff outputting strings does have tests around it, and should be pretty good…but it is also an aspect of the library that I do not currently use in any projects, so it has been low priority for me to beef it (or the docs) up any. Contributions welcome.
Is there a way to tell a load to not delete keys when the entity it pulls from the remote has fewer keys than where it’s loading it into? I’m using multiple comps with the same ident and different numbers of keys (summary and detail), but the one with fewer keys is causing the extra keys to get deleted when it loads. hmm I guess it’s complicated because it’s difficult to differentiate between a query using fewer keys vs the keys having been deleted on the server. Cache invalidation is one of the hard things of CS
You can use a component with the same ident but keys in its query that match what the remote is returning.
yes I’m using multiple comps with the same ident and different keys, but the one with fewer keys is causing the extra keys to get deleted when it loads
If matching then no deleting should happen. You can be using a different component for loading than the one that's on the screen.
or I’m switching between two different comps with the same ident -> summary and detail. would that do it?
The special loading component is just loading into app state. You don't really even have to think about what is on the screen.
yes I’m doing that also, but sometimes I just load summaries, and sometimes detail, but when I load summaries, those are erasing the detail i already loaded
Don't use either (summary or detail). Use a special component just for the load, and you might have many of these 'load only' components.
and what if I sometimes want to load many keys, and sometimes only a few, and I don’t want the one that loads a few to erase the many?
Have many 'load-only' components, as many needed, each one matching exactly what the server returns.
The server is designated as the source of truth. So if the client asks for a key and the server does not return that key, then it is assumed that the key has been deleted on the server, so it is also deleted on the client.
my comp was set to automatically load on mount and I was using it for a new client-side created entity, so it was erasing all of the new values
Glad it is all working. Even thou it is a simple rule, takes experience to be able to work with it.
yeah it’s been working great, I just didn’t analyze my problem right in the beginning
TBH I think the original message should also stay. Anything to help others. This is a common 'trap' that people fall into.
Thanks for the excellent answer @tony.kay
Hi, I've been watching the excellent videos by @tony.kay. I am able to use href
for dynamic routing, but when I type the URL in, it returns 404. How can I intercept the URL before it gets to the server?
@hadilsabbagh18 you don’t, you have to make the server respond with the index page for all valid routes, and then once your app is loaded look at the URL and fix your application state
I’m having a strange problem with a couple of non-fulcro UI components not rendering until the next render cycle (using the keyframe2 renderer):
(do
(debug "RENDER DataEntryDate" DataEntryDate)
(ui-datepicker {:selected DataEntryDate
:onChange #(when (inst? %)
(log/debug "date change" %)
(set-value! this :sitevisit/DataEntryDate %))}))
I’ve verified that the render debug statement reports the correct value should be getting handed to the datepicker, but it doesn’t get displayed until the next render-causing changeremember that rendering is predicated on shouldComponentUpdate, which looks for prop changes…if props don’t change: no render….otherwise kr2 renders everything
so it’s behaving as if the datepicker’s :shouldComponentUpdate is false, but then it’s true on the next round