This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-30
Channels
- # aleph (4)
- # beginners (24)
- # boot (15)
- # cider (4)
- # cljs-dev (37)
- # clojure (73)
- # clojure-losangeles (1)
- # clojure-serbia (1)
- # clojure-spec (27)
- # clojurescript (78)
- # core-logic (3)
- # datascript (9)
- # datomic (10)
- # events (1)
- # lein-figwheel (1)
- # lumo (2)
- # off-topic (14)
- # om (6)
- # om-next (1)
- # parinfer (18)
- # pedestal (2)
- # protorepl (4)
- # re-frame (2)
- # reagent (56)
- # specter (6)
- # unrepl (2)
hmm with that counter in place, it looks like my nav gets re-rendered after every successful http request
if an atom gets swapped with its current value, does it count as a change and cause a re-render?
@deadghost this will help https://github.com/Day8/re-frame/wiki/When-do-components-update%3F
Note in particular, half way through where I explain: > Wait. Is that it? Why doesn't the [more-button counter] component rerender too? After all, its prop counter has changed???
I haven't read that document in a long time. Realised it is slightly out of date in the Changed?
section
I'll make a quick update
ehhh are there any reasons why dispatch-sync
would not load all the data before running the initial mount after it?
and it appears I'm getting the same results whether I'm using dispatch
or dispatch-sync
I'm using a combination of http-fx
, async-flow-fx
, dispatch-n
and perhaps one of those might not play nice with dispatch-sync
?
afaik dispatch-sync
simply executes your handler directly, this doesn't apply to any effects your handler might have. So if you want your application to wait for data before rendering checkout https://github.com/Day8/re-frame/blob/master/docs/Loading-Initial-Data.md
@deadghost it sounds as if you need to initiate a multi-step boot process, where some of the steps are async?
Have I understood correctly?
Yep, so the HTTP bit means there's async steps
A round trip to the server
dispatch-sync
is a (slightly cheating) means of calling the event handler NOW rather than SHORTLY. It is a means of getting a certain state into app-db
which might include setting a :booting?
flag.
But if that event handler ALSO returns effects which are themselves async then those processes will be kicked off, (HTTP GETs will be initiated) but the response will arrive later.
We set :booting?
flag in app-db
to true
. Then the views can render a starting twirly thing, conditional on that flag being true
The final booting async process (HTTP GET?) sets that flag back to false
Which causes the views to render the full app for the first time
Lots of variations on that theme possible
@gadfly361 (or anyone else): I'm trying to port a small project from re-com to soda-ash. I'm a newbie to semantic-ui. Any good examples I can look at?
@deg I dont have any open source projects that use it. However, did a github search and came across this, which is pretty minimal and easy to grok: https://github.com/Ionshard/gamegrue/blob/master/src/cljs/gamegrue/youtube/views.cljs
this is the website: http://gamegrue.com/#/
your best resource will likely be the official sementic ui react docs tho: https://react.semantic-ui.com/introduction
I'm starting with an input field. Looks like a big conceptual difference between this and re-com is that re-com wraps a layer around getting values in and out of fields, while soda-ash and semantic-ui look much more like straight html?
yeah, re-com is a little more opinionated and comes with some helpful things baked in like this: https://github.com/Day8/re-com/blob/master/src/re_com/misc.cljs#L119-L126
for example my nav starts at state {:foo 1 :bar 2}
, does one http request that replaces that entirely with {:foo 1}
=> re-render 1 then does another http request that brings it back to starting state {:foo 1 :bar 2}
=> re-render 2
@deadghost i would either use promise composition or re-frame-async-flow-fx to avoid delivering the intermediate state into your app-db
@mccraigmccraig how would you do it with async-flow-fx?
first request set a flag :update false
or something, second request brings it to true and that triggers re-render
@deadghost i’ve not used async-flow-fx myself yet - i’ve always gone the promise composition route
it’s pretty easy with promise composition - i’m using the alet
and mlet
macros from cats with promesa
hmm thought this should suppress all re-renders :should-component-update (fn [] false)
How would I call a function on a component? Like if i wanted to call postMessage
on a WebView
in re-natal.