The life plugin tracks a spirits lifecycle. Oftentimes a spirit would use it to retrieve the lifecycle status of another spirit.

var otherspirit = gui.get('#thatspirit');
console.log(; // true

Lifecycle flags

The lifecycle status of a spirit is reflected in a set of boolean properties. These are all readonly, or at least they should be.

Spirit is constructed? This is almost certainly true by the time you address the spirit.
Spirit is configured? If true, the spirits (other) plugins are ready to be used.
The spirit is now or has ever been positioned in the DOM?
The spirit is currently positioned in the DOM? Note that this is initially false until the spirit has been discovered by the framework. It is also false whenever detached is true.
The spirit is currently not positioned in the DOM? Note that this is initially true until the spirit has been discovered by the framework. It is also true whenever attached is false.
The method onready has been called on the spirit? If true, this implies that all descendant spirits are also ready.
The spirit has entered the phase of it's life that happens roughly 4 milliseconds after ready?
The spirit is destructed? If true, don't try anything funny. The spirits properties and (other) plugins may not even exist.

Perhaps refactor something to allow undefined as a third state for these booleans?

Lifecycle listeners

You can add like an event listener to get notified whenever a spirit transitions into a new lifecycle phase. This is particularly useful for plugins, as they would otherwise need to rewrite the spirits methods.

onconstruct: function() {
onlife: function(l) {
	if(l.type === gui.LIFE_ATTACH) {
		this.spirit.dom.parent().className = "container";

The callback method recieves a gui.Life object with two properties type and target where the target is always a spirit. Note that this is a "non-bubbling" type of event, so you need to get a hold of the spirit in order to listen for it. We recomment you add listeners using this list of constants.

  • gui.LIFE_ENTER
  • gui.LIFE_READY
  • gui.LIFE_ASYNC

The constants map down to strings, but we can reduce the risk of typos by using the constants instead of the strings. That's because the plugin has been rigged to explode on undefined.

Custom events

You can make up new lifecycle events as you go along. = true;'copypasted');