[erlang-questions] Perform gen_event:call/3 inside Module:handle_event/2
Thu Oct 25 19:11:50 CEST 2012
On Thu, Oct 25, 2012 at 11:40 AM, Dmitry Kolesnikov
> you could achieve dynamic behavior through add_handler/add_sup_handler and
> The major point here you are re-using existed OTP function.
I think you and I have a different understanding of the dynamic behavior I
mentioned. By using just one module with the support of callbacks list, I
could handle the event without knowing the handler's behavior beforehand.
If I use add_handler/add_sup_handler, it will add a lot of callback module
into the event manager and the number of handlers is equal to the number of
callbacks, even when some callbacks are for the same event type. If I use
one module with dynamic callbacks, the number of handlers is equal to the
number of event types, and I can support more.
> The requirement to accure all of the state of another event handler might
> be challenging.
> I believe you need to
> a) either execute callback in dedicated process spawn(fun() ->
> Callback(Payload) end)
I am actually going this route.
> b) re-factor your listener concept where event handlers independent. I
> would propose to follow-up this way.
I don't think it matters whether event handlers are independent. Event
within an even handler, I cannot do gen_event:call to get the state of a
different event handler.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions