11 hours ago · Tech · 0 comments

I have in mind a caller-id feature for PubSub. Good time to do this, when users are few. Bears arrive unexpectedly. We need a sort of long-range communication in our program, and we have the PubSub object to let us deal with that. We use the facility to enable a dungeon item (model) to announce something that the view needs to deal with, such as the fact that the object is being removed. And we use it to enable one dungeon item to inform others that something has happened. The Button announces that it has been pressed, and the corresponding AppearingConten appears. Sometimes, the subscriber to an event really only wants to hear from one object, if that one publishes. In the case of the Button, we deal with this with a hack: when a button is pressed, it prepends its name (a string) to the message, and the AppearingContent knows the same name. So the Button says ‘a secret key button_pressed’ and the AppearingContent subscribes to that event string. That’s rather clearly a hack, and it…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.