This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-28
Channels
- # aleph (3)
- # babashka (66)
- # beginners (96)
- # calva (45)
- # clj-kondo (28)
- # clojure (30)
- # clojure-dev (2)
- # clojure-europe (20)
- # clojure-germany (22)
- # clojure-norway (4)
- # clojurescript (176)
- # clojutre (1)
- # cursive (23)
- # datalog (6)
- # datomic (7)
- # docker (3)
- # emacs (3)
- # exercism (4)
- # figwheel-main (5)
- # fulcro (8)
- # gratitude (9)
- # hyperfiddle (8)
- # introduce-yourself (2)
- # jobs (2)
- # malli (4)
- # membrane (3)
- # off-topic (17)
- # polylith (3)
- # portal (2)
- # re-frame (27)
- # reitit (3)
- # releases (1)
- # remote-jobs (1)
- # shadow-cljs (152)
- # spacemacs (8)
- # tools-deps (15)
- # vscode (1)
- # xtdb (24)
Another documentation clarification question: Whenever any event is triggered, all reg-sub query functions are automatically run. Is that correct?
it happens in a cascade, because first those that depend directly on db, and then those that depend on those reg-sub that have recalculated
Is there a document where docs explain that multiple rf/subscribe
calls does not create multiple nodes on signal graph?
Sorry, to multiple rf/subscribe
calls to the same subscription. For example:
(for [x (range 10)]
[:span (<sub [:foo])])
I don’t remember if sometime I read that this does not create multiple reaction
s (low level). I’m thinking on performance.
Indeed, corresponding reactions are cached, so in that case only one reaction is created.
From the docstring of subscribe
:
**De-duplication**
Two, or more, concurrent subscriptions for the same query will
source reactive updates from the one executing handler.
Although I guess the wording is quite opaque when you don't know that the cache exists. :) In any case, the implementation of the caching is also rather straightforward.
I remember that was explained in one of the md
docs, but maybe I did read it from there.
Thanks
This is the closest related one that I know of: https://github.com/day8/re-frame/blob/master/docs/FAQs/Why-Clear-Sub-Cache.md
Hello. Is there a way to compose several event-fx (particularly of the :http-xhrio
kind) in way similar to how promises compose in JS? I have a chain of events the should execute in order, and each event should take the output of the previous one, some of these events are http requests and I would like to have a general error handler for these requests instead of one per request. Currently I have a bunch of separate effects and each one points to the next either by calling the next in the :fx
vector or on the :on-success
or :on-failure
keys of the :http-xhrio
. However the approach seems somewhat verbose and the flow is hard to grasp for people other than the one writing the code.
Maybe this will help, although I haven't used it myself: https://github.com/ingesolvoll/re-chain
Thanks!
I haven't used re-frame in a while and I can't remember how fx & cofx work.
How do I express the loading of a file via js/FileReader
and its subsequent callback from (.addEventListener reader "load" callback-fn)
in terms of fx & cofx ?
If we abstract away the specifics, all that's left is the need to handle an async operation.
With that being said, coeffects don't support anything async, but effects do.
So what you can do is create an effect for reading files and pass something like :on-read
to it which would be an event fired by that effect with the file's contents once the reading is done.
Is there a way to dispatch an event that reframe reacts to from outside re-frame? (ok if it’s super hacky, like could you put the reframe dispatch
function on the window and call that from inside another framework, like Vue or React, or plain JS?) any other crazy ideas that might work for something like that?
Just use something like
(ns a.b
(:require [re-frame.core :as rf]))
(defn ^:export dispatch [event]
(rf/dispatch event))
And then in JS you'll be able to do a.b.dispatch(some_cljs_vector)
.perfect.. was going down this road, this might just work :face_vomiting:
context is trying to strangle a very out of date app.. re-writing the whole thing in one go isn’t feasible, but slowly migrating one component at a time as we have to change might be.. re-frame for the new version might be an option, so curious if anyone has tried anything like this.
Hey when loading initial data on a route using reitit frontend what is the idiomatic way. I know it can be done using the controllers, but it feels very weird to call dispatch inside a router. Have any of you found another way or is this is very reitit specific?
I think controllers is the common way to initialize some specific data of a route. There is an example on reitit repo: https://github.com/metosin/reitit/tree/master/examples/frontend-re-frame
You could also initialize data on main (`init!`) using dispatch-sync
(maybe also using https://github.com/day8/re-frame-async-flow-fx) but that is application data. It depends of what you need.
Okay, I'm interested in lazy loading only the necessary data for each route (sub application) since the app is quite data heavy. But if it is idiomatic to use re-frames dispatch within the controllers that's probably okay. I'm only afraid that it will crash with other events, but since re-frame uses an event queue it will probably be okay(?).