Question

I have three main views in my application: A, B and C. Each of these views contain a view called X. Clicking a button in the X view dispatches a FooEvent to the event pool.

I would like to map multiple commands to the FooEvent and execute one of them depending on which main view (A, B or C) is currentry visible. I would have to add an if clause to every command mapped to FooEvent checking if the correct view is visible and I don't like this. Distributing logic across commands makes them hard to manage.

What is the best way to conditionally call commands in the context my application?

Was it helpful?

Solution

Inside X mediator you can create a listener for a FooEvent. and then based on X parent you dispatch new Event.

Or inside A,B and C you listen for FooEvent, and when you catch it you mediate it from A,B or C mediator to specific command.

The goal is to keep view events inside views, and to mediate new communication further

You can also use Signals

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top