Fork me on GitHub
#re-frame
<
2017-07-19
>
danielneal07:07:54

@pandeiro @mikethompson I use async-flow-fx to good effect. Nice to separate the higher "control flow" handlers from the http-call-and-put-in-the-database handlers which might be reused

danielneal07:07:59

I'm interested in this statement at the end of the readme: A motivated user might also produce a fully general FSM version of this effects handler.

danielneal07:07:09

is that a genuine proposition? would it be useful? how would it look

ajs08:07:21

In this talk from ReactConf, the presenter talks about the automatic memoization of re-frame subscriptions and how this can lead to some unpredictability. Can anyone shed some light on what he means? https://youtu.be/-jwQ3sGoiXg?t=651

mikethompson08:07:26

@ajs I'm not aware of any unpredictability with the signal graph.

ajs09:07:46

ok, wonder what he was talking about. He's a developer for Khan Academy and the presentation is pretty interesting look at different state paradigms for interacting with React.

mikethompson11:07:43

@ajs he doesn't mention how re-frame is different to Redux in terms of effects, which seems a significant miss also.

pesterhazy14:07:47

When using the debug interceptor, I'm seeing messages like Handling re-frame event: printed twice. Any idea why that might be?

pesterhazy14:07:58

AFICT the functions themselves are invoked only once

pandeiro14:07:18

Is it a known issue that a :textarea with its :value attribute bound to some derefed subscription value effectively becomes read-only (`:on-change` events never fire, keyboard input is blocked)? If so, what's the best pattern for clearing a textarea, say after a submission (but where the form remains rendered)?

curlyfry16:07:32

That sounds strange, it works for me. My guess is that re-frame isn't the culprit here.

pandeiro17:07:30

Hrm. Yeah I don't get why this behavior happens sometimes and not other times.

souenzzo15:07:55

Anyone doing something like this: [bit off topic] - Client requests data - Server process the request, get the result, do a "signature" to result and send both to client - Next client request, the client says "yout last result has this signature", server process, with new result, check if it's equal to the the client sent, just response "ok", else send the new response and the new signature

lsenta15:07:16

Sounds like a Bloom Filter with 1 hash function

pesterhazy17:07:31

If anyone is curious about my "duplicate logging" issue, it was an issue with the docs: https://github.com/Day8/re-frame/pull/379

pandeiro20:07:47

So in the simplest repro I could come up with, having a [:textarea {:value @(subscribe [:some-thing]) :on-change #(dispatch [:other-thing (.-value (.-target %))])}] renders the textarea essentially read-only, because while the change events do fire, the value of the textarea is set back to the subscription value immediately and the new input is never shown. Is this the expected behavior?

pandeiro21:07:48

Argh, so no, not what should happen -- and I was observing that because of some processing of the input that was blocking new values from being dispatched.

talgiat20:07:24

@mikethompson after few days with the new re-frame we've converted most of our handlers (with their middlewares) to the reg-event-fx that return a map of effects. We've also created some custom effect (for analytics, api calls and the likes). One issue that came up was conditional side effects, for example conditional dispatching. We've written a custom effect for that called dispatch-n-cond which receives a map of events and booleans, and will dispatch only the events to which the boolean is true (similar idea to https://www.npmjs.com/package/react-classset for conditional css classes). Thus we're replacing code (conditional expressions) with data, but it feels a bit like we're making up effects DSL of sorts. How are you handling conditional side effects in your code?

mattly20:07:37

@talgiat :dispatch-n seems to not mind having nil in the collection you provide it, I'm not sure this is officially supported but I just use when inline in the vector I provide to dispatch-n

mattly20:07:41

actual example from my code

talgiat20:07:36

@mattly, wasn't aware of that, but seems to do the trick is well. Our custom effect is :dispatch-n-cond and will be uses like this:

{dispatch-n-cond {[:collections/set-local-storage] true
                               [:collections/add-item (:id data) (:guid add-item) (:type add-item)] (some? add-item)
                               [:modal/close] true}}

mikethompson22:07:06

Historical note ... if I had my time over again I would have made effects be a paired vector ...

mikethompson22:07:42

[:dispatch  [:one] 
 :dispatch  [:two] 
 :http      {:url .... }]
One of the annoying things about the current map approach is that we have dispatch and dispatch-n. This problem (1 or N of effects) tends to play out for many effects.

mikethompson22:07:55

The additional benefit is that you get ordering of effects (not that this is a very big deal) But there are cons. Finding and updating the :db effect in an :after fn of an interceptor would have suddenly got a whole lot more complicated (is trivial ATM)

mikethompson22:07:31

The challenges of being a DSL designer !!

mattly22:07:16

@mikethompson I'm learning a bit of that myself while extracting something from my current work project into a library

mattly22:07:32

there's quite the balance to be struck

mattly22:07:10

that said, I think the map is easier to test, and I would have made :dispatch a vector of vectors

mattly22:07:46

I must budget some time to upgrade to 0.9x soon

mikethompson22:07:50

@pandeiro can you use on-blur, rather than on-change ?

pandeiro22:07:18

@mikethompson Yeah, that is probably a good idea

pandeiro22:07:41

I remember re-com does that by default, right?

mikethompson22:07:02

re-com gives you the option

mikethompson22:07:08

If you absolutely have to use on-change then I'd use dispatch-sync

mikethompson22:07:22

Otherwise fast typing by the user can cause problems because there is a tiny async loop in there.

mikethompson22:07:55

Even with dispatch-sync super fast typing can be a problem

pandeiro23:07:32

Is there a way to inject the print debugging for all events without manually including the interceptor vector for each reg-event-db/`reg-event-fx`?