Search code examples
flashactionscript-3apache-flexmodel-view-controllerparsley

How does the Parsley Framework Messaging System Work?


I am trying to use parsley framework in my flex application. Messaging System is one of the best feature that I see while using parsley,

But I had a doubt,

Does using Parsley framework in your application means that,

  1. Replace every addEventListener() functionaltiy with the Messaging System of Parsley ?
  2. Cannot create any objects using new newObject();. Should use dependency Injection, instead of creating explicit objects ?

Are the above doubts true ?


Solution

  • No. Using Parsley does not mean you must/should replace all your event listeners with Parsley's messaging.

    The whole idea of Parsley is to decouple, in other words, it's about making parts of your app not tied to other parts of your app.

    You CAN decouple using Flex Messaging, because Flex events can transvers. But: 1) Flex events transvers through the display list which is not always what you want 2) Flex events depend on String, which can be a pain if you refactor, or make typos

    So the answer to both your questions is: Only use Parsley events and Parsley objects if you want Parsley to manage those objects. Which will not be the case always.

    Decoupling can be good, but it can be a chore. Unlike the previous answer. Decoupling is GREAT for unit testing. It actually makes it easier, because in theory, everything is a unit by itself not tied to other Units. Just because Parsley can inject them for you, it doesn't mean it HAS to do it for unit testing.

    Actually, Flex is built around Injection. There is a difference between automatic injection and injection. When you assign a dataProvider to a List, you are Injecting, it's just that your are doing it manually. Parsley simply offers a way to manage Injection automatically for you.

    However, yes, sometimes you might be wondering why something didn't get injected, but it is not that difficult to figure out why.

    I wrote a series of posts to help people get going with Parsley, check it out http://artinflex.blogspot.com/2010/09/quick-dive-into-parsley-intro-why.html it might be useful.