Hello,<div><br></div><div>I would like to know if it is possible to write an event handler that would receive only certain notifications based on a simple criteria.</div><div><br></div><div>For example, say I have a server process that searches for USB devices, and sends notifications whenever new devices are attached or detached. I would like to write a event handler that would register to only certain kind of devices (based on an atom describing the device for example) or another event handler that would match all devices.</div>
<div><br></div><div>I have tried to use different function clauses like :</div><div><br></div><div>* in a module :</div><div><div><div>handle_event({attach, device_type_A}, State) -> ...</div><div><div>handle_event({detach, device_type_A}, State) -> ...</div>
<div><br></div></div></div><div>* and, in another module :</div><div>handle_event({attach, device_type_B}, State) -> ...</div><div><div>handle_event({detach, device_type_B}, State) -> ...</div><div><br></div></div>
<div>And register those two event handlers with the same manager. Unfortunately it fails with a bad_function_clause error. I was expecting that, but I'm running out of ideas.</div><div><br></div><div>Am I overlooking something?</div>
<div><br></div><div><br></div><div>Best Regards,</div><div>Camille</div><div><br></div></div>