How to use Announcements?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use Announcements?

R. Tyler Croy
I'm having trouble figuring out how to use announcements, I'm assuming they're
similar to existing JavaScript events, but I'm not clear on how I should be
creating them, firing them or consuming them.

Any documentation on them would be appreciated :)

- R. Tyler Croy
--------------------------------------
    Code: https://github.com/rtyler
 Chatter: https://twitter.com/agentdero

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to use Announcements?

Manfred Kröhnert
Hi,

On Sun, Jan 6, 2013 at 7:16 AM, R. Tyler Croy <[hidden email]> wrote:
I'm having trouble figuring out how to use announcements, I'm assuming they're
similar to existing JavaScript events, but I'm not clear on how I should be
creating them, firing them or consuming them.

Any documentation on them would be appreciated :)

- R. Tyler Croy

first you need an instance of Announcer.
The SystemAnnouncer for example can be obtained through

  announcerInstance := SystemAnnouncer current.

You can also create your own single instance of Announcer or a subclass of it.

Then you need a class for each announcement (see SystemAnnouncement and subclasses).
Announcement classes don't necessarily need any methods.

Sending announcements is as easy as:

  announcerInstance announce: AnnouncementClass new.

For receiving announcements you have to register a callback for the desired announcement class like the following:

  announcerInstance on: AnnouncementClass do: [:announcement | "do something when announcement occurs"].

Hope this helps.

Best,
Manfred