Share 'Invalidation & LifeCycle' on Delicious Share 'Invalidation & LifeCycle' on Facebook Share 'Invalidation & LifeCycle' on Google Bookmarks Share 'Invalidation & LifeCycle' on Twitter

  1. What is invalidation?
  2. What is a component life cycle?
  3. What is Invalidation & LifeCycle?
    1. Invalidation (I10N)
    2. LifeCycle
  4. Comments (9)
  5. Leave a Comment

Invalidation & LifeCycle

The lifecycle package of AS3Commons UI solves the problem of creating and updating visual components in a comprehensible, structured and performant way.

Read the LifeCycle introduction to get familiar with the meanings of Invalidation & LifeCycle.

The package contains two services (Invalidation and LifeCycle), of which Invalidation is an abstract and customizable invalidation manager and LifeCycle is a configuration of the first and provides a ready-made component life cycle. Both take use of the following workflow pattern:

If you know Flex, Invalidation is an alternative to the Flex LayoutManager, LifeCycle is an alternative to the entire Flex component life cycle.

You use I10N when you are planning to create your own custom component life cycle. You use LifeCycle when you right away want to start developing performant components.

What is invalidation?

Invalidation is an asychronous design pattern in which the setting of a property is decoupled from the actual visual update of a component. Properties may change concurrently and multiple times. The visual update is yet executed only once.

The pattern requires the existance of an update scheduler. Whenever a property changes, the component schedules a visual update. After an amount of time (often at the end of the current frame) the scheduler is triggered and processes all objects added.

Having an invalidation service your component could use the following implementation to delay expensive visual updates:

public class MyComponent {
  private var _property : String;
  private var _property2 : String;
 
  public function set property(property : String) : void {
    _property = property;
    InvalidationService.invalidate(render);
  }

  public function set property2(property : String) : void {
    _property2 = property;
    InvalidationService.invalidate(render);
  }

  private function render() : void {
    // apply some drawings
    // layout children
  }
}

What is a component life cycle?

A life cycle is a convention of how components are created, initialized, drawn, updated and disposed. A life cycle takes use of the invalidation pattern to organize visual component updates. Additionally, the life cycle manages all the other aspects.

Using a life cycle will:

  • help you to add functionality to the right places
  • increase the performance of your component
  • reduce the amount of code you need to write
  • let you feel your components are well implemented

Having a component life cycle system you usually create a component from a base class that implements all necessary life cycle methods:

public class MyComponent extends BaseComponent {
  private var _property : String;
 
  public function set property(property : String) : void {
    _property = property;
    super.invalidate();
  }

  override protected function init() : void {
    // set up event listeners
    // set default values
  }

  override protected function createChildren() : void {
    // create child objects
  }

  override protected function render() : void {
    // apply some drawings
    // layout children
  }

  override protected function dispose() : void {
    // remove event listeners
  }
}

What is Invalidation & LifeCycle?

A component life cycle is a core part of every component framework. The best-known life cycle implementation is the Flex component life cycle with its familiar methods invalidateProperties(), invalidateDisplayList(), createChildren(), updateDisplayList(), ....

Any life cycle has its custom implementation of the invalidation pattern. Nevertheless, this is a very common problem that can be easily generalized. The Invalidation manager of this package (I10N) is such a generalization. You can use and configure I10N and put your own life cycle around. I10N is configurable to a large extent and fits to any need.

The LifeCycle system is made for those, who don’t want to spend time in creating their custom component life cycle. It’s a ready-made and out of the box usable system.

Invalidation (I10N)

I10N is a phase based validation manager for visual components. Once registered a component may schedule updates to a later date and will then be notified automatically at the time the update should be executed. You typically use I10N not directly but you customize the system to create your own component life cycle. The chart below shows the workflow of I10N. Click to enlarge.

See the Invalidation documentation for detailed information and usage examples.

LifeCycle

LifeCycle is a ready-made component life cycle built around a configuration of I10N. You simply plug in LifeCycle into your components, and you will get a clean and reliable component state management. The chart below shows a simplified workflow of LifeCycle. Click to enlarge.

See the LifeCycle documentation for detailed information and usage examples.



9 Comments

  1. _wqu

    1. Juni 2011

    Great work!

    I’will try to use it in my next project.

  2. bFunc

    13. Juni 2011

    LifeCycle really looks useful, it’s what I was thinking about for a long time.
    But I have different kinds of troubles when trying to integrate lifecycle into my project.
    for example, I just changed package name in
    BoxLifeCycleExample.as and then got
    [Fault] exception, in Invalidation.as line 291: information=ReferenceError: Error #1069: Property org.as3commons.collections.framework:IBasicMapIterator::key not found on org.as3commons.collections.framework.core.LinkedMapIterator and there is no default value.

  3. Jens Struwe

    14. Juni 2011

    You need to include AS3Commons collections 1.3. This should solve the problem.

  4. bFunc

    14. Juni 2011

    tnx a lot, u r right. Update solved the problem

  5. Matt

    13. Oktober 2011

    This library looks great… except for the silly naming, which is probably reason enough for me to NOT use it. Naming is important, especially in a library.

    Please consider changing your “clever” naming for the invalidation portion of this library (“I10n”). In the age of intellisense editors, it doesn’t help typibility, and severely hurts readability because it looks too much like the existing “l10n” moniker (commonly used as an abbreviation for “localization”). I’m not a fan of the common “l10n” (or “i18n”) namings either, but at least they are well-known.

    “i10n” is just confusing — “invalidation” would be a much better name.

  6. Jens Struwe

    13. Oktober 2011

    Thanks for the suggestion, Matt. I always love to read your issue reports and comments.

    The naming I10N is not as “clever” as you might think. An earlier version of Invalidation was implemented as a static utility where you had to operate extensively on the class name instead of an instance name of your choice. Shortening the class name was a compromise to keep the client code cleaner and more readable.
    Nevertheless, I understand your problem and will consider a re-renaming for a future release.

    By the way, could you recommend alternatives to this library to all of those people who also do NOT use it because of the annoying wording?

  7. klub kawy

    19. November 2015

    I’m not sure the place you’re getting your info, but good topic.
    I needs to spend a while finding out more or working out more.

    Thank you for wonderful info I used to be in search of this
    information for my mission.

  8. dota2hack.org

    13. Januar 2016

    Hello Facebook operates great yet your site is running slowly which took just about a minute to successfully load up, I am not sure whether it
    is my very own problem or perhaps your website problems.
    Anyways, Thanks for putting up such type of great articles.
    I’m guessing this has become beneficial to many people who came here.
    I personally should state that you actually have done superb job with this plus hope to find many more great things through you.
    I now have you saved to my bookmarks to look at new stuff you publish.

  9. windrivermoney.Faith

    3. August 2016

    I have been exploring fⲟr a little fοr any high quality articles օr
    blog posts on tyis ҝind of housee . Exploring in Yahoo І at
    lɑst stumbled ᥙpon this site. Studying tɦis info
    So i am glad to convey tҺat I havе a verү juѕt гight uncanny feeling
    I discovered jսst ᴡһat I needed. I ѕo much indisputably will make sure tο don?t put out of yоur mind thіѕ site and provides іt а look on ɑ continuying basis.

Leave a Comment

You have a question or have experienced an issue? Please post it in the forum: http://sibirjak.tenderapp.com/ in order to make the discussion available at a more central place.