PureMVC
Home
About
Code
Docs
FAQ
Forums
News
Showcase
Contact
Jobs
Welcome,
Guest
. Please
login
or
register
.
May 24, 2013, 01:15:23 AM
News:
ATTENTION: Spambots must die! Humans must visit
http://contact.futurescale.com
to request forum access.
PureMVC Architects Lounge
Announcements and General Discussion
General Discussion
[Feature Request] Having Typed Notification
Pages: [
1
]
« previous
next »
Author
Topic: [Feature Request] Having Typed Notification (Read 1967 times)
Flapflap
Courseware Beta
Newbie
Posts: 4
[Feature Request] Having Typed Notification
«
on:
December 13, 2007, 03:39:32 AM »
Hi there,
With the INotification's getBody() Object return type. We can not override the getBody() method to have a typed object handled in our Notification.
Sad, beacause having typed Notification can be very usefull and errorless.
Maybe in 1.7.
I'm ready to write the code if needed.
Thanks
Logged
pedr
Port to AS2
Full Member
Posts: 27
Re: [Feature Request] Having Typed Notification
«
Reply #1 on:
December 16, 2007, 04:40:17 AM »
Why not subclass Notification and add your own getter / setters much as you would when building a new Event class?
The getBody() is there as an easy, untyped way of passing data, but if you need strict typing, just add it to your subclass.
Happy to send you an example if needed.
Logged
Kristopher Schultz
Newbie
Posts: 1
Re: [Feature Request] Having Typed Notification
«
Reply #2 on:
January 14, 2009, 11:30:28 AM »
pedr,
If one were to create a subclass for a particular type of Notification - say a notification which carried a User object as it's payload and had a getUser() method - how would you get PureMVC to use that subclass? The method signature of sendNotification() doesn't allow you to specify which INotification implementation to use.
Kris
Logged
Jason MacDonald
Sr. Member
Posts: 243
Re: [Feature Request] Having Typed Notification
«
Reply #3 on:
January 14, 2009, 01:10:49 PM »
Use
notifyObservers
.
«
Last Edit: January 14, 2009, 01:13:51 PM by Jason MacDonald
»
Logged
puremvc
Global Moderator
Hero Member
Posts: 2790
Re: [Feature Request] Having Typed Notification
«
Reply #4 on:
January 15, 2009, 09:56:37 AM »
Typed notifications are exactly what the framework was trying to avoid. Believe me, I'm sold on the power of strong typing, but in this case, I wanted simplicity.
IMHO, Custom Events are such a pain to have to create if you want to throw a piece of data over to another actor. The actor has to be listening for the specific type and you have to create the class. Once you start making custom Events (or Notifications) its like the 'bet you cant eat just one' commercial; you end up with a plethora of them to manage. If you have a team and a codebase in flux, often code gets refactored not to use an existing custom event but the class remains, since other parts of the code use it, and no one knows when to get rid of it. You have to figure out what to name them, etc. In short it can become a hairball that is not even remotely worth the hassle.
In a system like Flash where you get a reference to an EventBroadcaster subclass and tell it to create a listener pointing to your method (which has a typed Event argument), typed Events make sense, in that the IDE can tell you something about the problem before you compile. The trade off (at least in flash.events.Event) is that you can't send arbitrary data with an Event. It just says something happened and here's the name of what it was and where it came from.
In the PureMVC implementation of the Observer pattern we trade that compile time knowledge of the type being sent and received for the decoupling of the actors (the observer doesn't need to know or have a reference to the subject, in fact the subject doesn't even need to exist at the time the observer is registered) and because of that we have a single inbound notification method that the notified parties receive their notifications on.
As Jason mentioned you can use facade.notifyObservers to send custom notifications, and feel free to do so, but I don't see the benefit. If you cast a received note body to the type you expect it to be, you still need to see if its null before making assumptions about it, do you not? Could you not have as easily as having got the type wrong, not loaded the body at all? Even if that body was typed, it could still be null. You can't catch everything at compile time, and this is one of those things that, again, IMHO, isn't worth trying.
-=Cliff>
Logged
Pages: [
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Announcements and General Discussion
-----------------------------
=> General Discussion
=> Getting Started
=> Architecture
=> Public Demos, Tools and Applications
===> Fabrication
-----------------------------
PureMVC Manifold
-----------------------------
=> Port Authority
===> Contributor Central
===> Client Side
===> Server Side
=> Port to AS2
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to AS3
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to ColdFusion
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to C++
===> MultiCore Version
=====> Demos and Utils
=====> Bug Report
=> Port to CSharp
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to Dart
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Haxe
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Java
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to JavaScript
===> Demos and Utils
===> Native JS Branch
=====> Bug Report
===> PrototypeJS Branch
=====> Bug Report
===> Objs Branch
=====> Bug Report
===> MooTools Branch
=====> Bug Report
===> ExtJS Branch
=====> Bug Report
=> Port to Objective C
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to Perl
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to PHP
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Python
===> Standard Version
=====> Bug Report
=====> Demos and Utils
===> MultiCore Version
=====> Bug Report
=====> Demos and Utils
=> Port to Ruby
===> Standard Version
=====> Bug Report
=====> Demos and Utils
=> Port to TypeScript
===> Standard Version
=====> Bug Report
=====> Demos and Utilities
===> MultiCore Version
=====> Bug Report
=====> Demos and Utilities
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Powered by SMF 1.1.11
|
SMF © 2006-2007, Simple Machines LLC
Loading...
Copyright © 2006-2008 Futurescale, Inc.