This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-09
Channels
- # aleph (3)
- # beginners (327)
- # calva (3)
- # cider (20)
- # cljdoc (59)
- # cljs-dev (40)
- # clojure (104)
- # clojure-dev (30)
- # clojure-italy (8)
- # clojure-nl (36)
- # clojure-russia (3)
- # clojure-spec (3)
- # clojure-uk (79)
- # clojurescript (54)
- # community-development (5)
- # cursive (28)
- # data-science (21)
- # datomic (35)
- # emacs (14)
- # expound (1)
- # figwheel (2)
- # figwheel-main (82)
- # fulcro (18)
- # graphql (13)
- # jobs (12)
- # jobs-discuss (38)
- # kaocha (8)
- # lambdaisland (1)
- # lumo (12)
- # off-topic (20)
- # onyx (4)
- # re-frame (51)
- # reagent (12)
- # reitit (8)
- # ring-swagger (1)
- # shadow-cljs (22)
- # slack-help (2)
- # spacemacs (6)
- # specter (16)
- # testing (3)
I have a cofx handler that must produce data from an async operation (a js promise). How do I do that?
I'd use the same approach as re-frame-http
hmm, re-frame-http is fx a handler, I want a cofx
Oh right. Sorry. cofx can't be async
events have to be handled, right there and then. There's no pausing, waiting.
In practice this is never a problem, but you might need to think about your problem in a slightly different way
I found this clarifying (from re-frame docs)
> coeffects is the current state of the world, as data
If there was something async going on, it wouldn’t be about “current state” but some uncertain future state of the World. 🙂 That would make it more difficult to reason about. It’s simpler if events
are the (only?) source for side-effects.
indeed
nicely said
great. Thanks
is there anything special I need to do to reload a subscription via the repl? I’m trying out a new workflow without figwheel reloading but just reloading code in the repl or is this generally a bad idea? I noticed that code changes in event handlers are picked up, but not in subscriptions.
Hey, any good resources that anyone can point me to that breaks down improving performance in re-frame?
I’ve gone over the usual suspects 😃 -> 1) https://github.com/Day8/re-frame/blob/master/docs/Performance-Problems.md 2) https://github.com/Day8/re-frame/blob/master/docs/SubscriptionsCleanup.md Some of it’s still a bit overwhelming, if anyone can point at more things that I can look at it would be really helpful =)… I’m pretty sure there’s more I can do.
@folcon I'm not aware of any other documents, but maybe describe your problems here and see if anyone here has tips?
Ok, so I’ve written a fair sized app, and it’s pulling in a lot of external data, so working out at a high level what areas slow-downs are coming from so I can investigate further would be useful.
I’m using the 10x, but it’s surprisingly hard to find issues unless I load in a lot of data, and then doing any kind of careful exploration is really problematic…
what's bad about your performance? slow view updates, memory use, CPU spinning?
If my [:input {:type :text...
has a value that is subscribed to and and :on-change that updates that value: Did I just create a an infinite loop? It seems to work but I am not comfortable with this code. Here is a gist with a sample https://gist.github.com/llsouder/971f21f8a5aea4bfd114f017a9418a2b
There’s no loop. It just keeps the state consistent between app-db and the input. This is very common in React world.
Is the reason there is "no loop" because the on-change dispatch value is the value in the text box so the subscribe doesn't trigger a render? Or does the text box stop a loop condition because the subscribe sets the value but then on-change is "not a change" so "no loop"?
When you type a
in the input, it goes to app-db and subscription reads it from there and sets components value to a
and it settles there.
In this case app-db contains the ‘truth’ about components state and not the input itself. In React world these are called “controlled components” https://reactjs.org/docs/forms.html#controlled-components
thank you, your explanation and the link answered a lot of my question, present and future. 😄
@braden.shepherdson Slow view updates and memory use are two big ones, I’ve done some fixes on cpu spinning by chunking work. A lot of react missing keys issues I’ve “fixed” by doing ->
(into [:div] (for [item @subscription] [:div ...]))
(Not that I’m certain it’s a good idea, but it worked.)One thing that’s currently on my list is working out a good way of batching up datascript
transact’s.
@folcon that doesn’t fix missing keys issue in terms of perf. React keys exists for more efficient diff’ing
So if you just don’t do them, you don’t get the perf improvement. I’d prefer the into like you have when there is no need for this perf boost
But they must be identifying keys. Not just positions in the sequence when things are changing the sequence in arbitrary positions later
So a static sort of list that isn’t going to benefit from this (doesn’t really change much across renders and/or is not very big), into
is fine. I have no idea your situations though.
It does assign a vector index value to the dom object right?
I’m pulling a large number of items out of datomic, so I should be able to use :db/id
, but I’m concerned about values with the same key in different parts of the dom…
The react key identifier is only a local identifier for that particular children component array
Ok, so just needs to be unique at the given level in the dom tree? I should probably swap to using db/id
everywhere then.
https://reactjs.org/docs/lists-and-keys.html#keys The couple paragraphs here explain it pretty well. But a key is only useful in the context of the surrounding sibling components.
The app I’ve written is pretty heavyweight and I’m really trying to see if there’s any obvious other things I’ve missed 😃
one step would just be to estimate the total size of your Datascript blob.
sometimes you're using your memory to store actual data, and not just overhead 😄