14 Using Observers to Clean Up Code

Goal

You’d like to decrease the dependency certain parts of your application have on other parts of it to keep things flexible and clean, especially when you need to take action in one part of your application when something in another part changes.

Solution

In Flex, use binding tags, BindingUtils and ChangeWatchers, to be notified when state changes occur in another part of the application.

In Rails, use the ActiveRecord lifecycle methods and observers to take action when certain events take place on your models.

BindingUtils and ChangeWatchers in Flex

As you’ve gone through this book and seen how powerful and useful Flex’s binding syntax is for cleaning up your code, you may have ...

Get Flex on Rails: Building Rich Internet Applications with Adobe Flex 3 and Rails 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.