Adobe Flex

Adobe Flex : When to fetch Data

A frequent question among Flex developers is the question about when to fetch data.
During what phase in the component lifecycle should the model layer be called and asked for data, and if not present already, should the model layer access the data layer and fetch the data.
Let me start by pointing out that there are many developers that unfortunately do it wrong.
Most developers use the non-ambiguous creationComplete event or even worse, the applicationComplete. However certain the component is to all children being available and all settings being set, it inflicts a major overhead for the component as it after data has been fetched is typically forced to invalidate itself and hence do all initialization one more time… this time just with data.

The answer to the question about when to fetch data is in short the initialize event. You can use the preInitialize but outside the scope of this post, there can be certain issues when doing it at this time.

So, in conclusion… fetch the data at the initialize event and NOT at the creationComplete.

Advertisements

One thought on “Adobe Flex : When to fetch Data

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s