Announcements question

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

Announcements question

hernanmd
Hi, I'm using AXAnnouncements but I suppose this question is valid for other implementations. In SASE (the "triggerEvent" event framework) one could subscribe an event for an object specifying an argument at registration time:

eventSource
  when: #eventName send: #aSelector to: anObject with: argument

I've looked at Announcements and it seems this kind of registration isn't supported without using blocks. Am I right?
Before getting into details I just want to check. What people do to specify an argument at registration time with Announcements?

Cheers,

Hernán


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Announcements question

keith1y

On 4 Nov 2009, at 21:50, Hernán Morales Durand wrote:

> Hi, I'm using AXAnnouncements but I suppose this question is valid  
> for other implementations. In SASE (the "triggerEvent" event  
> framework) one could subscribe an event for an object specifying an  
> argument at registration time:
>
> eventSource
>   when: #eventName send: #aSelector to: anObject with: argument
>
> I've looked at Announcements and it seems this kind of registration  
> isn't supported without using blocks. Am I right?
> Before getting into details I just want to check. What people do to  
> specify an argument at registration time with Announcements?
>
> Cheers,
>
> Hernán

Your announcement is an object of your own design. You can put  
parameters as instance variables in your announcement subclass.

The default implementation does not support the ability to send  
methods to objects in the manner that you describe.
My Wandering Announcements package does have an enhancement to support  
this,
it is available in the squeaksource.com/Jetsam repository.

Keith
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Announcements question

hernanmd
Hi Keith, thanks for your reply.
I've tried your implementation a bit this way:

| testAnn |
testAnn := WAAnnouncer with: { 1 . 2 }.
testAnn
    subscribe: AnnouncementMockA
    send: #value:
    to: ExampleObject new.
...
testAnn announce: AnnouncementMockA.

but in ExampleObject>>value: anObject

anObject happens to be an AnnouncementMockA and not { 1 . 2 } which is what I'm trying to achieve. I know I can do anything with the AnnouncementMockA at signalling time, but I have the collection { 1 . 2 } only at registering time.
Do you have an example of this behavior with your implementation?

Just thinking, I'm wondering why a subscriber must be a class :

    eventSource
        subscribe: AnnouncementMockA
        send: #value:
        to: anObject.

but not an instance, it could be:

    eventSource
        subscribe: ( AnnouncementMockA named: 'a' with: argument )
        send: #value:
        to: anObject.

this way would prevent announcement class explosion too.

Hernán

2009/11/4 keith <[hidden email]>

On 4 Nov 2009, at 21:50, Hernán Morales Durand wrote:

> Hi, I'm using AXAnnouncements but I suppose this question is valid
> for other implementations. In SASE (the "triggerEvent" event
> framework) one could subscribe an event for an object specifying an
> argument at registration time:
>
> eventSource
>   when: #eventName send: #aSelector to: anObject with: argument
>
> I've looked at Announcements and it seems this kind of registration
> isn't supported without using blocks. Am I right?
> Before getting into details I just want to check. What people do to
> specify an argument at registration time with Announcements?
>
> Cheers,
>
> Hernán

Your announcement is an object of your own design. You can put
parameters as instance variables in your announcement subclass.

The default implementation does not support the ability to send
methods to objects in the manner that you describe.
My Wandering Announcements package does have an enhancement to support
this,
it is available in the squeaksource.com/Jetsam repository.

Keith
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Announcements question

keith1y

On 4 Nov 2009, at 23:58, Hernán Morales Durand wrote:

> Hi Keith, thanks for your reply.
> I've tried your implementation a bit this way:

Ok, the package is SeaWA-Core,

First of all we add a double dispatch back to the Announcement,  
enabling the Announcement subclass to be able to specialize announcing  
policy. e.g. the default is to announce to all dependents, but you  
might want to announce to all dependents that meet a certain criteria.

The class comment describes this as follows:
======
Unlike normal announcers which figure out what to announce to whom, as  
much responsibility is given to each Announcement as possible so that  
behaviour can be overriden completely for different scenarios.

When handling an announcement we double back and send #announceTo: to  
the announcement itself to give it complete control, over what it does  
before or after informing dependants. Its default behaviour is  
#dependantsAnnounce . This allows an Announcement to replace the  
behaviour of Announcer-#dependantsAnnounce: altogether if it wants to.
========

A second enhancement is to return the announcement from the invocation  
of the trigger. Though I cant remember exactly why this is now.

=======
Triggering example: (we always return the original announcement)

theAnnouncement := self announcer announce: (SomeAnnouncement param:  
arg1).
=======

Now here we come to the interesting bit.

===============
Subscriptions example:

self announcer on: SomeAnouncement do: [ :announcement | ...  ].
self announcer on: SomeAnouncement send: #tellMe: to: anObject.

Normally, the announcer is passed as the argument, however, each  
announcement class defines  #args, so it can call a method that is not  
expecting an Announcement as the parameter. This enables you to wire  
up objects that were not designed with announcements in mind.

example trigger:
self announce: (HtmlUpdateAnnouncement on: html)

self announcer on: HtmlUpdateAnouncement send: #renderOn: to: anObject.

where:

HtmlUpdateAnnouncement-#args
^ Array with: html

=================


does that help?

Keith



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Announcements question

Stéphane Ducasse
I would really like to have a nice chapter on announcement and  
variation  for the next pharo by example 2.
Simon started to write something and if somebody want to help you are  
welcome.

Stef
On Nov 5, 2009, at 2:57 AM, keith wrote:

>
> On 4 Nov 2009, at 23:58, Hernán Morales Durand wrote:
>
>> Hi Keith, thanks for your reply.
>> I've tried your implementation a bit this way:
>
> Ok, the package is SeaWA-Core,
>
> First of all we add a double dispatch back to the Announcement,
> enabling the Announcement subclass to be able to specialize announcing
> policy. e.g. the default is to announce to all dependents, but you
> might want to announce to all dependents that meet a certain criteria.
>
> The class comment describes this as follows:
> ======
> Unlike normal announcers which figure out what to announce to whom, as
> much responsibility is given to each Announcement as possible so that
> behaviour can be overriden completely for different scenarios.
>
> When handling an announcement we double back and send #announceTo: to
> the announcement itself to give it complete control, over what it does
> before or after informing dependants. Its default behaviour is
> #dependantsAnnounce . This allows an Announcement to replace the
> behaviour of Announcer-#dependantsAnnounce: altogether if it wants to.
> ========
>
> A second enhancement is to return the announcement from the invocation
> of the trigger. Though I cant remember exactly why this is now.
>
> =======
> Triggering example: (we always return the original announcement)
>
> theAnnouncement := self announcer announce: (SomeAnnouncement param:
> arg1).
> =======
>
> Now here we come to the interesting bit.
>
> ===============
> Subscriptions example:
>
> self announcer on: SomeAnouncement do: [ :announcement | ...  ].
> self announcer on: SomeAnouncement send: #tellMe: to: anObject.
>
> Normally, the announcer is passed as the argument, however, each
> announcement class defines  #args, so it can call a method that is not
> expecting an Announcement as the parameter. This enables you to wire
> up objects that were not designed with announcements in mind.
>
> example trigger:
> self announce: (HtmlUpdateAnnouncement on: html)
>
> self announcer on: HtmlUpdateAnouncement send: #renderOn: to:  
> anObject.
>
> where:
>
> HtmlUpdateAnnouncement-#args
> ^ Array with: html
>
> =================
>
>
> does that help?
>
> Keith
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Announcements question

hernanmd
In reply to this post by keith1y

2009/11/4 keith <[hidden email]>

On 4 Nov 2009, at 23:58, Hernán Morales Durand wrote:

> Hi Keith, thanks for your reply.
> I've tried your implementation a bit this way:

Ok, the package is SeaWA-Core,

First of all we add a double dispatch back to the Announcement,
enabling the Announcement subclass to be able to specialize announcing
policy. e.g. the default is to announce to all dependents, but you
might want to announce to all dependents that meet a certain criteria.

The class comment describes this as follows:
======
Unlike normal announcers which figure out what to announce to whom, as
much responsibility is given to each Announcement as possible so that
behaviour can be overriden completely for different scenarios.

When handling an announcement we double back and send #announceTo: to
the announcement itself to give it complete control, over what it does
before or after informing dependants. Its default behaviour is
#dependantsAnnounce . This allows an Announcement to replace the
behaviour of Announcer-#dependantsAnnounce: altogether if it wants to.
========

A second enhancement is to return the announcement from the invocation
of the trigger. Though I cant remember exactly why this is now.

=======
Triggering example: (we always return the original announcement)

theAnnouncement := self announcer announce: (SomeAnnouncement param:
arg1).
=======

Now here we come to the interesting bit.

===============
Subscriptions example:

self announcer on: SomeAnouncement do: [ :announcement | ...  ].
self announcer on: SomeAnouncement send: #tellMe: to: anObject.

Normally, the announcer is passed as the argument, however, each
announcement class defines  #args, so it can call a method that is not
expecting an Announcement as the parameter. This enables you to wire
up objects that were not designed with announcements in mind.

example trigger:
self announce: (HtmlUpdateAnnouncement on: html)

self announcer on: HtmlUpdateAnouncement send: #renderOn: to: anObject.

where:

HtmlUpdateAnnouncement-#args
^ Array with: html

=================


does that help?

Now I see the potential (the double dispatching is actually a scenario where making Announcements as classes does make more sense).

Although I can adapt the api with your approach, my issue is a situation where I want to keep the current interface (supporting Announcements transparently) and, at the tech level, setting up widgets inside containers which broadcast events both at asynchronous (with AJAX) and synchronous submission time, under this scenario, it is necessary to catch the contained arguments at subscription time for setting up its notification. Otherwise, if I choose to notify at signalling time, I have to select for all of them later which could be inefficient since they could be nested at many levels.
Anyway today, with an amazing lack of inspiration, I wrote an extension to the implementation to write something like:

    eventSource
        subscribe: ( AnnouncementMockA with: argument )
        send: #value:
        to: anObject.
 
Just for the record, if someone needs this feature, it would be in the next SmallFaces release.
Cheers,

Hernán

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project