Pregunta

From time to time I've encountered scenarios where several complex conditions need to be met prior to triggering an event. Furthermore, most listeners also run additional checks to determine the course of action. This got me thinking whether a better solution would be to think in terms of smaller events and let them trigger inside each other.

Chaining events would allow me to weave in any additional listeners later on with fairly low effort (possible violation of YAGNI?). My code would consist of simple easily understood elements, which shouldn't be difficult for others to understand.

However, the possible downsides to this solution would be the fact that should something happen to go wrong in the chain (e.g false event triggering due to human error), it would be quite difficult to catch the bug.

Is event chaining a good ideaTM? If not, what are the alternative methods to keep event related code getting cluttered?

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
scroll top