|
I apologize if this is posted in the wrong place.
I am taking a course based on Nand2Tetris and we are tasked with building a game in Jack. I intend to build a version of breakout. Instead of having objects tightly coupled to each other, I wanted to implement a publish/subscribe pattern in which objects communicate via a central EventsBroadcaster object. Objects would subscribe to events via EventsBroadcaster.subscribe() and publish events via EventsBroadcaster.publish(). When an event is published, EventsBroadcaster would look up every object subscribed to that event and call its on() method. That method would have the signature on(String event, Data data) where Data is just a dummy class. In reality any object could be passed via data and the receiving object would just have to "know" what fields to access. I thought that maybe this would work because of Jack's lack of type checking, but I suspect that this will result in symbol lookup problems. If Jack will not support this, is there any way to implement something close to this in Jack?
Thanks in advance for any help.
|