Importance of Context Object in Parsley

Context is the heart of Parsley Framework which keep every other part/object of the framework alive. So any object, which want to live in Parsley environment, should be linked with its Context. Any object which is not linked to context is not actually live for Parsley, as no body part can live without supply from heart.

Above is the artistic definition. The technical point is that, context is the object where Parsley framework keeps all the information for all linked objects. Context is the single shared object among all the components, and parts of the Parsley. So if any part of parsley needs any object, it can ask the single shared context for the object. Similarly, context is important in initialization and un-initialization of objects and manage their life cycle events as well.

So context is the storage of all the live objects in Parsley framework. Any object can be asked from the context at anytime during execution.

And the object, which is not in context, is not live for Parsley.

Now Parsley features are available to the objects only which are live i.e. if their existence is known to Parsley framework. For example, only those objects can dispatch and consume the events which are live for parsley. Similarly dependency injection will also work till the object is in context. Many a times, developers face the problem like their object is either not dispatching the event or not consuming the event, a major debug point can be to ensure that this object is still in context of Parsley. Objects can be released from Parsley context due to various reasons like

  • Dynamic commands releases from context as soon as these get the result or error from service call.
  • View objects releases from the context as soon as their parent window gets closed

So be careful for the object life cycle and always code to consume all the events before the un-initialization of the objects.

People who read this post also read :



0 comments:

Post a Comment