This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-12
Channels
- # adventofcode (2)
- # aleph (2)
- # announcements (5)
- # aws (5)
- # babashka (25)
- # beginners (167)
- # calva (8)
- # cider (1)
- # clj-kondo (3)
- # cljsrn (19)
- # clojure (87)
- # clojure-conj (7)
- # clojure-dev (19)
- # clojure-europe (1)
- # clojure-italy (14)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-spec (18)
- # clojure-uk (29)
- # clojuredesign-podcast (3)
- # clojurescript (40)
- # clojurex (11)
- # core-async (13)
- # core-logic (2)
- # cursive (16)
- # data-science (4)
- # datascript (10)
- # datomic (53)
- # emacs (1)
- # events (15)
- # fulcro (71)
- # jobs (1)
- # jvm (2)
- # malli (4)
- # nrepl (2)
- # pathom (74)
- # re-frame (1)
- # reitit (19)
- # remote-jobs (1)
- # rewrite-clj (18)
- # ring (2)
- # shadow-cljs (132)
- # spacemacs (22)
- # tools-deps (65)
@tony.kay did you experiment with react hooks a while back? I vaguely remember a use-fulcro
something? was that something you actually implemented?
It would not be terribly hard to do, I just have no personal need for it, and have other things I am trying to get done 🙂
yeah no worries. just thought I could maybe use it to figure out how to get my vdom stuff play nice with fulcro 🙂
If I remember right, you have no need of Fulcro controlling targeted refresh, right? Your macros kind of figure out what can change and auto-target it?
I have most of the vdom stuff figured out and working. not ready for public use but working.
I have some basic db normalization working too but I'd much rather not re-invent all that stuff and just let fulcro do it 🙂
There really isn’t a lot to it. The ident-optimized render algorithm would be pretty much unchanged, except you would not call React’s setProps
, but would instead trigger whatever your equivalent is for refreshing a component.
the indexes need to be built for the on-screen components by a componentDidMount equivalent…see defsc code for what that looks like…
Glad to integrate any level of “plug-in” support you need to make it easy to select as an option. I guess to make it seamless we’d have to figure out how to get the defsc
code generation working right…but I think that’s mostly in the configure-component!
function now, so it would actually probably be pretty easy…just macro madness in terms of making sure the “hook” is configured before anything compiles.
(defc ui-root [props state]
[query
(app/query [::filtered-todos
::editing
::num-total
::num-active
::num-completed])
(defc todo-item [{:keys [todo]} state]
[{::keys [completed? editing? todo-text]}
(app/query todo [::todo-text
::editing?
::completed?])
btw one thing I experimented with is creating a TransactedData
type that basically acts like a map and delegates to the actual state
cool..interested to see where that goes.
So, if I were tring to set up Fulcro with an alt rendering system, here’s what I’d do:
1. I’d make some way to configure which function is used by defsc instead of the hard-coded configure-component!
2. I’d figure out something similar for setting the function to call instead of setProps
in ident-optimized render
There’s already a way to set what function is root-render!
.
Then you should be able to make something that works with unmodified Fulcro apps (but either ignores or implements the lifecycle methods, of course).
components just need to be able to return their options map (see component-options
) for all of the core algs in Fulcro itself.
I doubt that unmodified fulcro apps can ever work. actually quite a few differences from react
so unlikely defsc
is gonna work. thats why I asked about hooks, that is much closer to what I have
So, Fulcro wants to render once from root, then is happy to have you control what renders afterwards.
but not sure why you think that unmodified Fulcro would not work (again, assuming you don’t use lifecycle methods)
except for hot code reload, which may call root-render with a “force” to force the UI to update
the ident-optimized render will also use root render if there is no ident on a component that needs refresh
Almost everything in Fulcro will work if your component sets up enough stuff to respond properly to the component-options
method (I think you’d also have to make it so that things like react-component?
return true…but yes, see where the code takes you. The component-options
support (the open map of options) is critical for most of the compat.
But there’s almost nothing special about React, and I can’t think of any reason why almost any approach wouldn’t work for rendering
but since js functions can have things just set on them, that should all be pretty easy
This might also help: http://book.fulcrologic.com/fulcro3/#_ui_refresh
The “refresh by UI keyword” requires the index from class->component
(on-screen component), which is constructed on the fly by React lifecycle normally.
@thheller I found the old code where I was playing with hooks…not sure how useful it is, but here it is: https://github.com/fulcrologic/fulcro/blob/feature/react-play/src/main/play/main.cljs