Fork me on GitHub
#re-frame
<
2018-01-16
>
Dos13:01:29

Is there any example of modifying interceptors queue inside a interceptor?(filtering in my case)

nrako16:01:57

I am interested in dispatching a re-frame event from native code (Android). Are there any resources that I can take a look at? I found this mentioned (https://clojurians-log.clojureverse.org/re-frame/2017-11-02.html) but was wondering if there were any resources…

kenny19:01:54

Out of curiosity, why are event handlers not stored in the registrar (`kind->id->handler`) in the same manner as all the other handler types (i.e. :fx, :cofx, and :sub)? Event handlers are stored as a list of interceptors instead of just a function, like everything else.

mikethompson21:01:30

@kenny the list of interceptors (with the event handler wrapped on the end) is indeed stored in the registry

kenny21:01:14

Right but I'm just curious about the asymmetry.

mikethompson21:01:29

Its all about how things are used

mikethompson21:01:53

event handlers, by themselves, are not interesting (to re-frame)

mikethompson21:01:04

The event handler "chain of interceptors" is interesting

kenny21:01:37

Sure. Is it ever used outside interceptor chain processing though?

kenny21:01:12

So then it seems like the interceptor processing could be wrapped up in a function and used as the value in the kind->id->handler map.

kenny21:01:49

The value for all other handler kind's is a function.

mikethompson21:01:56

What is stored is what is needed (by re-frame)

kenny21:01:59

Was the "Yes" in response to using a function as the value for events in the registrar?

mikethompson21:01:16

A wrapped version of the handler you supply is what is stored

kenny21:01:39

I am talking about doing the same for events.

mikethompson21:01:44

What is stored is what re-frame needs. Not directly what you supply

danielcompton21:01:13

I think what @kenny is saying is that you could store a partial function which closes over the vector of interceptors?

kenny21:01:22

precisely

mikethompson21:01:33

Anything is possible. Use case? (I have to go ... but will cycle back later and read)

kenny21:01:01

I was just looking into Spec integration with re-frame. It seems like a really clean integration point would be to wrap all the functions stored in the registrar with a function that validates the event/query vec. I have a POC of Spec integration written without doing that and it seemed a bit verbose, given all the handlers are registered using the same mechanism.

kenny21:01:14

I think you could essentially have a single integration point for Spec, which would be really nice.

kenny21:01:47

Something like:

(fn validate-fx
  [params]
  (if (valid? params)
    (handler params)
    (throw-invalid-spec params)))

kenny21:01:01

where handler is the value stored in the registrar.