Fork me on GitHub
#re-frame
<
2016-11-02
>
curlyfry08:11:47

How would I do a try/catch on the exception thrown by an event handler in an interceptor? In 0.6.0 we could just surround the call to the (handler) with try.

mikethompson21:11:53

@grant it is for dynamic subscriptions. See the docs folder

mikethompson21:11:35

@joshkh it sounds like you want to create a reusable re-frame component. You want to use the "data table" in a new application.

shaun-mahood21:11:00

@grant: I think https://github.com/Day8/re-frame/wiki/Dynamic-Subscriptions is the most recent documentation on dynamic subscriptions, it's a bit out of date but should explain it well enough.

mikethompson21:11:06

@grant There is only one app-db ever, so you'll want to "parameterize" the component, so that a new use of it works on a different path (new instance) within app-db

mikethompson21:11:26

@grant so the trick is to parameterize the "subscriptions" and the "dispatches" with this path.

mikethompson21:11:42

We use a technique we call dispatch-back which is like a merge between a dispatch + callback.

mikethompson22:11:56

So the component (data table) would be given a parameter like xyz (this is kinda like giving a callback to a component) and then the component will conj xyz onto whatever events is normally dispatches. The xyz is assumed to uniquely identify the "instance" of the data table to be manipulated.

mikethompson22:11:13

One of these days I'll get around to writing this stuff a bit more

mikethompson22:11:01

Think about it this way .... You'll notice that re-com's reusable components all take (as arguments) 1. a "reactive source of data" (a ratom) and 2. a callbacks for updates So one level up ... at the level of re-frame component ... you use the same architecture. Except the source of data will be a subsciption and the updates happen via a dispatch rather than a callback. But those subscriptions and dispatches have to be paramaterized by xzy.

shaun-mahood22:11:24

@mikethompson: I would certainly be interested in seeing a basic example whenever you have time for it, seems like a useful pattern

grant22:11:19

@mikethompson Thanks for the info, I'll read the docs that @shaun-mahood mentioned and see if I can wrap my head around it.

joshkh22:11:55

(just saw the notification @mikethompson), Yup, that's exactly right. I want the re-frame based data table to be integrated into another project.

joshkh22:11:51

I'm guessing that if I include the project as a dependency then I'll be able to dispatch events to the component, but I'm guessing that would also dispatch events to all instances of the component.

joshkh23:11:27

My naive instinct is to give the component a map of events to dispatch that override the events inside the component project but that doesn't sound clever to me.