tags:

views:

50

answers:

1

Hi there. I am using a lot of custom GWT events which 100's of objects need to register to receive. Is there anyway I could automatically register types of classes with each other. Or is there simply no way around it, the event handler manger needs the references to all the objects wanting to receive events. Would I be better off implementing my own type of event bus system? Any idea's on the matter would be most helpful thanks.

Edit: Example

Lets say I have over 1000 walls objects that make up a maze in which the walls can be moved around to find an exit and 200 NPC and 1 player Object inside the walled maze. Every time one of the players/NPC's hits the wall an onCollision the event is fired. So for all the wall objects to receive this event they most all register with the player and npc's. Seen as there are 1000 wall objects that quite a bit of registering.

So what I am asking is, is there a way predefine that any object of type wall will receive event type onCollision form any object of type NPC or player.

+1  A: 

Use an event bus. Have every NPC and the player fire CollisionEvents and have all wall object listen in on it. Ray Ryan provides some code about 14 min into his excellent GWT speech at Google I/O last year. http://www.youtube.com/watch?v=PDuhR18-EdM

dagge
That was most helpful, although I think I actually watched that video before ages ago and completely forgot about the eventBus system. Many thanks for your reply dagge
Ciarán
Ain't no thang ;)
dagge