Fork me on GitHub
#re-frame
<
2018-02-13
>
danielcompton00:02:41

@seako, what would it be promising?

seako00:02:12

oh, that the event will be handled in the future

danielcompton00:02:32

And the promise is fulfilled when the event is handled?

seako00:02:41

precisely

seako00:02:55

i used this sort of hybrid event/promise style in the past with https://github.com/gaearon/redux-thunk

danielcompton00:02:52

What is using the promise? Another dispatching event or the view?

danielcompton00:02:16

There is re-frame-async-flow-fx as another take on this

seako00:02:19

i use async-flow-fx and like it for composing events together but i dislike that i find myself writing a lot of book-keeping type events that serve only to signal to the flow that something finished

seako00:02:43

which is to say that my do-thing thing-success thing-fail thing-complete events all make me feel like i'm very verbosely going through the process of writing my own artisanal promise in data

danielcompton00:02:11

right, I understand what you're saying

agold02:02:52

My re-frame + re-com app works fine with :simple optimization but :advanced fails. Can’t see any errors or missing externs. Advice on debugging?

danielcompton02:02:49

@agold what do you mean by "fails"?

agold11:02:18

The app stops responding to clicks on a button and an svg element with a click handler.

agold11:02:42

No error messages appear, however.

agold12:02:01

Correction. With :advanced optimizations, I get this error when clicking on button: Uncaught Error: No print-fn fn set for evaluation environment

agold12:02:02

Setting google.DEBUG true in project.clj seems to have fixed this, so :advanced optimization now works. But false was produced by template. I have no print stmts in my code.

agold19:02:54

Problem is this: clicking dropdown arrow prints following error to console: render false {:loading? false, :error nil, :choices [], :id 0, :timer nil} But choices vector-of-maps is defined, and choices render correctly. There is no :id 0. So not sure why this is happening.

danielcompton19:02:04

There's really not enough information in there to be able to tell what's going on sorry, can you try maybe with a video showing the page + console?

agold19:02:50

http://agmardor.com/public/index.html Open the console and click the dropdown box labeled “Clock Multiplier"

danielcompton20:02:09

Ok, I can see nothing happens, but that doesn't mean anything to me

danielcompton20:02:32

After clicking start/stop that dropdown works

agold20:02:51

It works for me without clicking start/stop, but only because I’ve enabled console printing. The re-frame + re-com template normally disables printing for the build with advanced optimization (by setting goog.DEBUG to false). When that happens, the dropdown doesn’t work because clicking it tries to print something to the console, which throws an exception. Anyway, thanks for your help. I will either figure it out or leave console printing enabled in the optimized version.

danielcompton02:02:33

@seako open an issue describing your use case, not sure if it would be part of dispatch, but I know the issue you're talking about

seako02:02:55

be happy to. thanks for listening to this half-baked idea.

shafeeq12:02:29

Hi, Is there is a way to add/replace interceptors for an event after/before it has been defined?

mikethompson12:02:16

In theory, it is possible for one interceptor to add remove further interceptors dynamically, at the time of execution.

mikethompson12:02:28

In practice, with re-frame, I'm not sure all the necessary API is in place, but it is ABSOLUTELY a feature of interceptor arrangements.

mikethompson12:02:57

You see, each interceptor's before fn is given a context

mikethompson12:02:08

And context contains the list of interceptors.

mikethompson12:02:37

So any interceptor can alter the set of future interceptors (by alterting what's in the context they were given, and which they return )

mikethompson12:02:26

So I'm answering this in two ways: 1. yes, in theory 2. in practice we may need to flesh out the available API / docs to make it possible/clearer

shafeeq07:02:43

Thanks, @U051MTYAB. I am looking to monkey patch a library. Thought adding interceptors is much better than redefining one of its events entirely. But as you suggested, I can add a default interceptor which can look for dynamically defined interceptors and chain them into the context.

arulpugazh13:02:34

Hi, a query related to reg-event-fx macro. I want to dispatch multiple events from a handler, but couldn’t get it working. I want something like this:

(rf/reg-event-fx
 :create-data-channel
 (fn [{:keys [db]} _]
     {:db (assoc db :initiator? false)
      :dispatch     [[:create-offer]
                     [:open-channel]]}))) 

manutter5113:02:25

You want :dispatch-n instead of :dispatch there

arulpugazh13:02:46

@manutter51 ah, cool. Thanks 🙂 It worked

gklijs22:02:09

When an :optimizations :advanced build doesn’t work completely, it would get no data from a graphql andpoint, and a :optimizations :simple does. What would be the way to figure out what’s going wrong with the advanced one? I suspect some strings which should’t be renamed do get renamed. Could it be because I referred to some events like

:open-bank.events/remove-transactions
?

mikerod22:02:53

@gklijs Don’t you always refer to events by their keyword name? Those shouldn’t be a problem for advanced optimization. I may not understand your question well enough though. You can do some debugging of advanced optimizations in general though via the :pseudo-names true cljs compiler options.

mikerod22:02:34

Also, I believe one thing that closure advanced optimization never changes are strings (your example is a keyword though). So again, I think I’m a bit confused by your question.

gklijs22:02:34

I never really ran into the problem before, I don't know where to look. It might be a problem in re-graph. It's weird because the data just doesn't come in.

mikerod22:02:45

Yeah, it could be a bit hard to figure out when you don’t have any errors to go from. If you sort of have isolated the place in the code where you are passing “inputs” and getting back the “output” that you are thinking has a problem though, you could add some js console print sort of things around it to try to see what is going on with advanced optimizations. Also, if you knew parts of the code you wouldn’t expect to have names changed on, you can do a search for that in the advanced optimization compiled js file and see what it looks like.

gklijs22:02:58

That are some good ideas, thanks.