Fork me on GitHub
#re-frame
<
2019-05-16
>
Louixs15:05:18

I may have missed something but does anybody know of a good way to check whether a handler/fx-handler has been registered, and only dispatch when it has been registered?

lilactown15:05:47

AFAIK there’s not an officially documented way to do that

lilactown15:05:09

I think the general assumption is that all handlers are registered at startup (or before they are needed)

lilactown15:05:02

there is re-frame.registrar/get-handler, which you could use to check the registrar to see if a handler with the ID you’re looking for has been registered. not sure how @mikethompson would feel about users leveraging that tho

👍 4
Louixs16:05:18

Hi @lilactown thanks a lot! I'll have a look at the get-handler function. To your point about registering all handlers at startup, I think I'm doing that but I'll have a second look to make sure that, that's actually the case.

mikethompson21:05:00

@ryuei.sasaki confirming: there's no official API for that, because, as @lilactown said, all handlers are registered on startup. My last statement is a white lie because you can, actually, dynamically add and remove handlers at a later point, which is what re-frame-async-flow does, but that is very unusual.