This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-21
Channels
- # announcements (2)
- # aws (1)
- # beginners (172)
- # boot (3)
- # calva (19)
- # cider (18)
- # clj-kondo (5)
- # cljsrn (18)
- # clojure (47)
- # clojure-europe (9)
- # clojure-finland (7)
- # clojure-italy (3)
- # clojure-nl (15)
- # clojure-spec (20)
- # clojure-sweden (2)
- # clojure-uk (72)
- # clojurescript (45)
- # cursive (42)
- # datomic (6)
- # duct (4)
- # emacs (4)
- # expound (48)
- # figwheel-main (7)
- # fulcro (64)
- # graphql (8)
- # hoplon (9)
- # hyperfiddle (1)
- # jackdaw (8)
- # jobs (4)
- # jobs-discuss (61)
- # klipse (5)
- # leiningen (6)
- # off-topic (72)
- # pathom (2)
- # planck (11)
- # re-frame (1)
- # reagent (3)
- # reitit (16)
- # remote-jobs (17)
- # ring-swagger (3)
- # shadow-cljs (49)
- # spacemacs (12)
- # sql (3)
- # tools-deps (124)
- # vim (64)
- # xtdb (4)
Update on Fulcro 3. Spent the entire day on it. I’ve got a full-stack TodoMVC running. Still a long way to go to round out APIs, but it’s nice to see it dancing. In an advanced compile build my new rendering optimizations cause fulcro to take about a half a ms to get the targeted update data for 2 of components, and the setStates that do the targeted props (in the release build of react 16.8.6) take on the order of 0.5 to 4ms. Of course, some of that setState time is element generation, but since Fulcro does those at compile time to js, those are basically a wash. It’s a simple app, but the design of the optimization should theoretically keep those times on that order even with a lot of things on screen (since it only updates the ones that really change, and that tends to be very few at a time).
Thanks for your great work, Tony. Regarding timing, I guess you're making a perfect version of Fulcro first, then adding a backward compatible layer later, right?
yes. If you look at the general code, the main thing that “looks” different at the moment is just namespaces Here’s the TodoMVC code that is running: https://github.com/fulcrologic/fulcro3/tree/develop/src/todomvc/fulcro_todomvc
Mutations, however, get a lot more powerful, and you can implement your own “load” with them, for example…see https://github.com/fulcrologic/fulcro3/blob/develop/src/todomvc/fulcro_todomvc/api.cljs#L130
that is different that “mutation joins”…the mutation (I’m prob going to call them “operation”) can send ANY AST now…and get the raw result…then use the built-in merge if it wants
So, making data_fetch API work “on top of that” will be trivial, but is necessary for source compat
All the internal mess that was due to shoe-horning onto Om Next is gone, so the internals are waaaay simpler to deal with. The transactional semantic stuff is the most complicated, but I’m going to make that optional…it is necessary for bw compat, but not necessary for new apps I don’t think
Also nice to know I can get an advanced compile to work on the first try….that was a nice change of pace…usually have to fight that one pretty hard
As a first step to building a custom remote, i'm trying to reproduce the "remotes as abstraction" code in my project
No method in multimethod 'cark.tags.options.background-remote/ls-mutate' for dispatch value: cark.tags.ui.options-page/set-some-key
i can make it work by namespacing everything to my background-remote namespace, but that's obviously wrong
so my question is, how do i namespace everything so that it's both modular and working ?
for now i did (defmulti ls-mutate (fn [_ key _] (symbol (name key))))
in background-remote. and (defmethod ls-mutate 'set-some-key ...
Hi @tony.kay, I am trying to test ident
queries, but somehow it does not work as I expected. Here is a sample code:
(defsc Ref1
[this props]
{:query [:title]
:initial-state {:title "some-title"}
:ident (fn [] [:ref 1])})
(defsc SomeData
[this props]
{:query [{[:ref 1] (prim/get-query Ref1)}]
:initial-state (fn [_] {})}
;;;;; props contain {[:ref 1] {}}, not {[:ref 1] {:title "some-title"}}
(dom/p (str props)))
(def ui-some-data (prim/factory SomeData))
(defsc Root
[this props]
{:query [{:ref1 (prim/get-query Ref1)}
{:some-data-list (prim/get-query SomeData)}]
:initial-state (fn [_]
{:ref1 (prim/get-initial-state Ref1 {})
:some-data-list [(prim/get-initial-state SomeData {})]})}
(map ui-some-data (:some-data props)))
The limitation is that components that query for NOTHING of their own (like SomeData) won’t work right
(defsc SomeData
[this props]
{:query [{:edge (prim/get-query Ref1)}]
:initial-state (fn [_] {:edge (prim/get-initial-state Ref1 {}})}
;;;;; props contain {[:ref 1] {}}, not {[:ref 1] {:title "some-title"}}
(dom/p (str props)))
ident queries in components are highly discouraged. Link queries (where the second element is _
) are meant for things like “logged in user” and “load marker table”.
in a static component definition, you typically don’t want to embed a static ident. If it really is a singleton, the edge invention above hurts nothing.
The one exception that is reasonable is if there is a singleton that you really do need to dynamically get to from various instances of a component, then it’s OK, but you have to be careful that your query contains something besides just the ref join
haha. thanks for your prompt answer. As you just said, I have different kinds of components that refer a singleton component.
I’ll try your suggestion using :edge
, but I am curious about :initial-state (fn [_] {:edge (prim/get-initial-state Ref1 {}})}
.
and :initial-state
has a non-lamba version that also error checks (and auto-wraps get-initial-state):
(defsc Root
[this {:keys [ref1 some-data-list]}]
{:query [{:ref1 (prim/get-query Ref1)}
{:some-data-list (prim/get-query SomeData)}]
:initial-state
{:ref1 {}
:some-data-list [{}]})}
(map ui-some-data some-data-list))
The maps in the non-lambda initial state are automatically turned into what you wrote by looking at the query
If I have that code, doesn’t it initialize the edge every time when an SomeData is created?