Please see the release notes for upgrade pointers.
Lifecycle.js is compatible with RequireJS, CommonJS, Brunch and AMD module loading. Module names:
A good example of this is Backbone.Articulation. Backbone.Articulation will reconstruct instances of Dates or custom classes within you Backbone.Model's attributes irregardless of what lifecycle model they use (as long as they use one of the known conventions!)
Manages the lifecycle of individual instances, objects, arrays, and object properties that comply with some lifecycle conventions:
Run time determination of the correct lifecycle for an instance:
instance =owned_copy_instance = LCowninstance # you don't need to know whether MyClass needs to get cloned, retained, etc...LCdisownowned_copy_instance # you don't need to know whether MyClass needs to get destroyed, released, etc
# works for arrays containing instances or primitive typesan_array = ‘hello’owned_copy_array = LCownan_array...LCdisownan_array# works for objects whose properties contain instances or primitive typesan_object = one: two: three: ‘there’owned_copy_object = LCownan_objectproperties:true...LCdisownan_object;
Very basic implementation following the Coffeescript class pattern for a reference countable class.
: ->super@is_alive = true: ->@is_alive = falseinstance = # ref_count = 1instanceretain # ref_count = 2instancerelease # ref_count = 1instancerelease # ref_count = 0 and __destroy() called
var MyClass = LCRefCountable;var instance = ; // ref_count = 1instance; // ref_count = 2instance; // ref_count = 1instance; // ref_count = 0 and __destroy() called