how do i dispatch an event from another event?
my initial guess is to write an effect but i would imagine this use case might be built in?
@benny there is a builtin effect :dispatch
thanks @mikethompson
Are there ways to listen to events and dispatching additional events on dispatch? Like enqueuing an event after another without the use the :dispatch effect? One solution is re async flow, but I wonder if there was something easier? The reason I am asking this is sometimes you want to have chain of events, but you want the definition of the chain outside the ancestor events.
Say you write events :a, then how do you hook event :b, without rewriting :a?
Do you want to always dispatch :b
when :a
is dispatched?
Yes, but maybe :c
But what if you don’t control :a
Then re-frame-async-flow-fx
does sound like the tool for the job.
Apart from that, re-frame has also introduced a thing called global interceptors. So you can create an interceptor that checks if the current event is :a
, and if so, dispatches :b
.
Thanks a lot!
async-flow-fx
uses https://github.com/day8/re-frame-forward-events-fx internally, may be worth taking a look.
Just dispatch
multiple events? Effects are processed right when the corresponding event is finished, so the ordering should be OK.
i ran into this funky issue: i use re-frame with shadow-cljs in electron, and i tried to push some hiccup into localStorage (accidentally). until i cleared localStorage the app wouldn't start up saying "no reader for tag object"
took forever to figure out what the issue was
Hmm. The component functions in the hiccup might have been the problem?
i think it was a pattern regex validation on an input field
the layers of escaping started to get confusing so i used a cljs regex and i think that was what caused the tag object error
General question - would it be desirable to highlight/post re-frame specific job openings in this channel? I know it was something I was looking for (prioritized before general Clojure jobs), but I’m not sure if it would add too much noise or be more annyoing than just putting them in #jobs and #remote-jobs
To be honest, I'm a bit surprised to see the "re-frame specific job" phrase at all. :) re-frame is a fairly simple library that won't take much of someone's time to learn if they read the documentation. E.g. I consider HoneySQL to be a much more complex library, but I doubt anyone puts it in the requirements list of a job opening.
I'm trying to generate at preview of a CSV file prior upload.
I'm using the node lib papaparser
which reads a file object from the event fired by <input type="file" ...>
My trouble starts when confronted with papaparser
parsing the files async which means that reg-event-db
is not the right way to go... but then what?
You can probably put everything that calls papaparser
into its own effect handler. You'd use that effect to start the parsing process, and the effect handler would itself dispatch some other event when the preview data is ready.
Over the last 4 years, I've seen maybe 20 jobs asking specifically for ClojureScript and re-frame knowledge.
Probably more
so extending cofx with a different handler than those like dispatch
and db
etc.?
@shaun-mahood I think probably in #jobs is best
Sounds good! @p-himik For me, looking for a re-frame specific job was all about avoiding complexity - I wanted something on the front end, and didn’t want to have to work with anything else if I could help it :)
@mikethompson Huh. Well, I am surprised. Despite of how useful and well thought out re-frame is, I would not require any candidate to possess the knowledge of it. @shaun-mahood Ah, I see - looking for a re-frame specific job is something else entirely. I was thinking of companies requiring candidates to know re-frame.
cofx == co-effects == input for event handlers fx == effects == output of event handlers I was talking about the latter. Yes, something like
{:papaparse {:data ..., :on-complete [:my-event]}}
Hello, can I track the cache invalidation of a re-frame suscription?