Indeed, each shared event dispatcher is only intended to be "shared" inside a given context. Having a truly "global" event dispatcher would probably not be such a great approach :)
You can use the ScopedEventDispatcherExtension to share additional event dispatchers between contexts. However, those sibling contexts will need a parent context with the ScopedEventDispatcherExtension installed if you want them to share dispatchers.
Let us know how it goes.
> --
> You received this message because you are subscribed to the Google
> Groups "Robotlegs" group.
> To post to this group, send email to robo...@googlegroups.com
> To unsubscribe from this group, send email to
> robotlegs+...@googlegroups.com
> for support visit http://knowledge.robotlegs.org
So, the ScopedEventDispatcherExtension does not rely on the Modularity extension or on the display list. It only looks to see if it should map local event dispatchers into an injector, or wether it can let those dispatchers be provided by a parent injector. In a loose sense it sort-of relies on the Modularity extension as it requires that *something* has wired the injectors together. But that wiring can be done manually (as we did earlier) if there is no display list to bubble events along.
Then I don't see the reason why the ModularityExtension is included in the basic bundle and the ScopedEventDispatcherExtension isn't.. but probably I'm just missing something, and the late hour doesn't help :)
Hey Shaun and Alessandro,
I agree that “global” isn’t a good name, but “shared” isn’t much better either, because a dispatcher can be shared within one Context, between all Contexts and between some Contexts. So, “shared” doesn’t say anything about the scope of the dispatcher.
After playing around with words I made a list of synonyms and a little diagram. It’s not easy to find good names for those dispatchers! So, you can either choose one from my list, or use it as an inspiration for further brain-storming.
1. within a Context (Shell or Module):
intra, local, restricted, internal, endo(gen), endemic, self, private, intrinsic
2. between all Contexts (Shell and Modules)
pandemic, omni(present), overall, public, extended, extensive, widespread, pervasive, spread, disseminated, scattered, ubiquitous, universal, general, cosmopolite, umbrella, overarching
3. between some contexts (ModuleA-ModuleB, Shell-ModuleA..)
scoped, joint, joined, targeted, F2F(Friend To Friend), limited
Then I narrowed it down to:
1. intraDispatcher, localDispatcher
2. panDispatcher, omniDispatcher
3. scopedDispatcher, jointDispatcher
or:
1. intraModularDispatcher
2. panModularDispatcher
3. scopedDispatcher
For example, in Module-A’s SomeMediator:
1. shared within Module-A’s Context
public var intraModularDispatcher:IEventDispatcher;
2. ScopedEventDispatcherExtension’s default dispatcher(“panModular” instead of “global”)
//context.extend(MVCSBundle, ScopedEventDispatcherExtension);
[Inject(name="panModular")]
public var panModularDispatcher:IEventDispatcher;
3. between Module-A and Module-B:
// context.extend(MVCSBundle, new ScopedEventDispatcherExtension("scopedAB ");
[Inject(name="scopedAB")]
public var scopedABDispatcher:IEventDispatcher;
My two cents ;)
Ondina--
Hi Avi,
You’re right, pan and omni aren’t ideal either! There are 2 aspects to it: the hierarchy and the accessibility. It’s hard to find a name describing both aspects clearly. I like your idea of hierarchy, but “super” and “sub” wouldn’t be of much help in a big tree either.
Just because 4 Modules are siblings, sharing the same parent, it doesn’t mean they automatically share the same dispatcher, but indeed it has to originate in the parent.
So, from Shaun’s example, Module-A and Module-B could share Bus1, where Module-C and Module-D would share Bus2. So Bus1 and Bus2 would be both “SuperDispatcher”, right? But if Module-B would have a child Module-D, and a shared Bus3, what would it be, super or sub dispatcher?
Maybe something like rootDispatcher, parentDispatcher, siblingDispatcher..? Not easy, really :)
Ondina
Hi Stray,
Good points!
>But I think this has saved us from a mistake - because the developer can now choose names >that represent purpose and not implementation-details.
>There will be a reason why modules A and B share a bus that modules C and D don't have >access to - that reason should be the source of the naming.
So, if Module-D would be a Service, then Module-A, B and C would share UserServicesMessageBus with Module-D in order to communicate with it. If Module-E were a logger, then we could have a LoggerBus shared by A,B,C,D and E.
The purposes are clear.
The purpose of what I called a localDispatcher or intraDispatcher is also clear.
And, indeed, it’s up to you as a developer how you name the dispatchers.
But what is the purpose of a „global“ dispatcher, or however we would name it?
Maybe there shouldn’t be a default dispatcher after all…
OndinaI had public and private on my lists too, so I like your idea!
So the default dispatcher would be ‘publicDispatcher’ or ‘publicBus’,
‘privateDispatcher’/’privateBus’
for the current module,
and maybe instead of ‘protected’ something like what Stray has suggested, denoting the purpose?
OndinaOr
1. centralBus
2. localBus
3. UserServicesMessageBus, OtherPurposeBus etc
--
>I thought the problem with global is that it's not truly global, doesn't "center" have the same problem?
True, it does…
But let us think how we would describe the default dispatcher in a sentence. It is provided by a parent context with the ScopedEventDispatcherExtension installed and it is inherited by its children? What else? What is its purpose?
Would ‘default’ or ‘defaultBus’ or ‘defaultDispatcher’ be better?
[Inject(name="defaultBus")]
public var whateverNameYouChoose:IEventDispatcher;
Actually, not much better, right?
Last ones for today:
[Inject (name="preset")]
Or
IYWYCHIBD =
If You Wanted You Can Have It By Default ;-)
[Inject (name="IYWYCHIBD ")]
Cheers