This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-29
Channels
- # announcements (9)
- # aws (1)
- # beginners (133)
- # boot (2)
- # calva (94)
- # cider (48)
- # cljdoc (7)
- # cljsrn (22)
- # clojure (128)
- # clojure-europe (22)
- # clojure-finland (7)
- # clojure-greece (6)
- # clojure-losangeles (3)
- # clojure-nl (81)
- # clojure-spec (30)
- # clojure-uk (60)
- # clojure-ukraine (1)
- # clojurescript (45)
- # core-async (26)
- # cursive (18)
- # datomic (12)
- # defnpodcast (1)
- # duct (4)
- # editors (4)
- # emacs (6)
- # fulcro (37)
- # graphql (4)
- # jobs (2)
- # jobs-rus (1)
- # juxt (7)
- # kaocha (2)
- # leiningen (1)
- # nrepl (22)
- # off-topic (2)
- # re-frame (16)
- # reagent (8)
- # reitit (22)
- # ring-swagger (5)
- # shadow-cljs (81)
- # tools-deps (4)
I need something like "on every state change, call my function". It can be "on every transaction, call my function" too
Fulcro is at the top of Hacker News right now: https://news.ycombinator.com/item?id=19520272
Thanks for answering all those questions and providing resources in the comments!
Thank you, I hope I was accurate!
Anyone have any ideas how to fix this? [fulcro.ui.form-state] FORM NOT NORMALIZED: [:update-booking :tab :booking]
it either means you didn’t add form config, or it is in app state nested as a map (instead of normalized to an ident)
(defsc BookingForm [this {:keys [_id rate] :as props}]
{:query [:_id
:rate
fs/form-config-join]
:form-fields #{:rate}
:ident [:booking/by-id :_id]}
(dom/div
{:style {:padding "35px 27px"
:backgroundColor "#fff"
:border "1px solid #DBDBDB"}}
(input-with-label this :rate "Rate")))
@tony.kay I’m going based off the form examples, all this appears correct - I must be missing something
ok, so to the query of the parent component thats passing booking
down, I need to add fs/form-config-join
?
wondering what the best way to accomplish the following would be: I have a component that needs to attach a non-react-supported event handler to an element. that event handler needs the component’s this
to be in scope so I can call transact!
and do something with the event data.
right now I’m just using a ref callback on the element and set!
ing the handler along with a ref on the component instance.
I’m actually instantiating and cleaning up the event handler in my componentDidMount
and componentWillUnmount
.
is there an easier way to add a method to an instance so it’s available with this
in scope in my componentDidMount
and componentWillUnmount
calls?
@njj afaik fulcro.ui.form-state/form-config-join
goes in the form’s query, and fulcro.ui.form-state/add-form-config
goes in the parent’s initial state creation call like {:my-form-data (fulcro.ui.form-state/add-form-config MyForm (fulcro.client.primitives/get-initial-state MyForm {}))
yep same thing. sorry, pulled that from a form of mine and my naming convention is a little different from what’s prob in the book
Weird, getting this error now: [fulcro.client.primitives] get-ident returned an invalid ident for class
sounds like you might not have a proper ident on your form component? I use something like :ident [:forms/by-id :form/id]
and then in my initial state will add :form/id :my-form
. you’ll want to make sure you add :form/id
to your query
my ident for my form is [:update-booking :tab :booking]
though, how would I make that work?
sorry for the late reply – I think of idents as having two pieces: 1) the table name in your app state. this could be :bookings/by-id
and then 2) the index/id/primary key within that table like :booking/id
. so your ident would look like [:bookings/by-id :booking/id]
it seems like you might be doing this in a top-level page? if so why not make a separate component with the ident you want to actually house this form/ui
for the form I’d do something like I mentioned above with the [:forms/by-id :form/id]
so that every form across your app is stored in the forms table in your app state
if you need to reference specific bookings you could have a ui of cards within the form that each have the ident of [:bookings/by-id :booking/id]
. just an example of how I might flesh this out
that way your router/page state, your form state, and your indiivudal booking state are all decomposed and placed in different parts of your app db for use elsewhere in the application
I created an app with lein new fulcro fapp1
When I start it, it pauses for a little over 3 minutes…
$ npx shadow-cljs server
shadow-cljs - config: /Users/eblood/tmp/fapp1/shadow-cljs.edn cli version: 2.8.25 node: v11.12.0
shadow-cljs - starting via "clojure"
[ 3:21 pause ]
19-03-29 21:26:05 2-3754.local DEBUG [fapp1.server-components.pathom-wrappers:11] - Registering resolver fapp1.model.user/all-users-resolver
19-03-29 21:26:05 2-3754.local DEBUG [fapp1.server-components.pathom-wrappers:11] - Registering resolver fapp1.model.user/user-resolver
19-03-29 21:26:05 2-3754.local DEBUG [fapp1.server-components.pathom-wrappers:11] - Registering resolver fapp1.model.user/user-address-resolver
19-03-29 21:26:06 2-3754.local DEBUG [fapp1.server-components.pathom-wrappers:11] - Registering resolver fapp1.model.user/upsert-user
shadow-cljs - HTTP server available at
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.8.25 running at
shadow-cljs - nREPL server started on port 9000
How would I determine what the pause is?
Also:
$ lein repl
If there are a lot of uncached dependencies this might take a while ...
REPL server launch timed out.
lein repl 66.67s user 1.38s system 105% cpu 1:04.49 total
$
@winkywooster what java version do you have? might be running into the user.clj related thing fixed in https://groups.google.com/d/msg/clojure/0YFGUdzCZ5U/bUW5SRO5BwAJ
Thanks @thheller, updating deps.edn
with org.clojure/clojure {:mvn/version "1.10.1-beta1"}
fixed the issue.