Fork me on GitHub
#re-frame
<
2018-01-24
>
caleb.macdonaldblack06:01:32

Is it okay to call a subscription from an event? Are there any issues in doing this?

caleb.macdonaldblack07:01:37

Ahh okay so an event and sub using the same function seems to be okay.

mikerod14:01:09

To me at least, there is a big more to this story.

mikerod14:01:18

There is this issue I believe that had more discussion on the topic: https://github.com/Day8/re-frame/issues/255

mikerod14:01:33

I think it can get difficult, depending on your circumstance, to just extract functions in subs and use them in event handlers. Sometimes subs depend on other subs and the stack of dependencies to call that function become non-trivial, or result in having to call a chain of functions.

mikerod14:01:40

If this doesn’t apply to your case, that’s good.

mikerod14:01:25

Which refers to re-frame-utils that does have a cofx for the purpose of accessing a subs in an event handler.

caleb.macdonaldblack04:01:33

@U0LK1552A Wow that is pretty much exactly what I need. The sub I’m using has input signals and is derived from multiple subs. Thanks!

mikerod04:01:30

I meant “bit more” just saw my typo. But yeah. Glad you found it useful

mikerod04:01:47

I’ve used it on several occasions for more complex subs

caleb.macdonaldblack04:01:36

Yea, I’m trying it out now. There is a performance caveat they mention that says: “Do not inject subscriptions unless they are also used in a component.“. This is fine though as we are using that subscription in a component.

mikerod20:01:18

Yep. It’ll warn you if you inject a subs that isn’t used elsewhere.

mikerod20:01:26

Definitely seems like something you’d want to avoid to avoid leaking.

danielcompton08:01:30

Following the re-frame release is a new re-frame-trace release. We've been working on this for quite a while, give it a spin! https://github.com/Day8/re-frame-trace/releases/tag/0.1.15

curlyfry12:01:36

New trace is fantastic! The "epoch-oriented" stuff works super well.

shaun-mahood16:01:43

Has anyone else pressed the "factory reset" button in the new re-frame-trace yet? It got rid of the entire panel for me and I can't seem to get it back 😞

danielcompton18:01:13

Ctrl +h should bring it back?

shaun-mahood19:01:06

That did the trick, thanks!