Skip to content

Commit

Permalink
Updated README. Moved min version to '.min' convention.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Malakoff committed Nov 18, 2011
1 parent d01eafd commit 5ecdbeb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
45 changes: 38 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@
Lifecycle.js provides conventions and helpers to manage the life cycles of Javascript instances.
````

## LC.own/LC.disown
Handles individual objects, arrays, and object properties that comply with some lifecycle conventions:
You can get the library here:

* Development version: https://github.com/kmalakoff/lifecycle/raw/master/lifecycle.js
* Production version: https://github.com/kmalakoff/lifecycle/raw/master/lifecycle.min.js

Introduction
------------
If you need to write code that manages the lifecycle of some javascript objects, but you don't know ahead of time what type of lifecycle model they implement, Lifecycle.js is for you!

A good example of this is [Backbone.Articulation][0]. 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!)

[0]: https://github.com/kmalakoff/backbone-articulation

# LC.own and LC.disown
Manages the lifecycle of individual instances, objects, arrays, and object properties that comply with some lifecycle conventions:

* clone() and destroy()
* retain() and release()
Expand All @@ -12,14 +25,32 @@ Handles individual objects, arrays, and object properties that comply with some

### Examples:

```javascript
var an_object = new Object(); var owned_copy_object = LC.own(an_object); LC.disown(an_object);
var an_array = [new Object(), ‘hello’, new Object()]; var owned_copy_array = LC.own(an_array); LC.disown(an_array);
var an_object = {one: new Object(), two: new Object(), three: ‘there’}; var owned_copy_object = LC.own(an_object, {properties:true}); LC.disown(an_object);
Run time determination of the correct lifecycle for an instance:
```coffeescript
instance = new MyClass()
owned_copy_instance = LC.own(instance) # you don't need to know whether MyClass needs to get cloned, retained, etc
...
LC.disown(owned_copy_instance) # you don't need to know whether MyClass needs to get destroyed, released, etc
```

It also works for Javascript collection types:

```coffeescript
# works for arrays containing instances or primitive types
an_array = [new Object(), ‘hello’, new Object()]
owned_copy_array = LC.own(an_array)
...
LC.disown(an_array)

# works for objects whose properties contain instances or primitive types
an_object = {one: new Object(), two: new Object(), three: ‘there’}
owned_copy_object = LC.own(an_object, {properties:true})
...
LC.disown(an_object);
...

## LC.RefCountable
Very basic class (following Coffeescript construction) for a reference countable class.
Very basic implementation following the Coffeescript class pattern for a reference countable class.

### Examples:
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ end

desc "Use the Closure Compiler to compress Lifecycle.js"
task :build do
minimize_with_header('lifecycle.js', 'lifecycle-min.js')
minimize_with_header('lifecycle.js', 'lifecycle.min.js')
end

desc "check, build and generate documentation"
task :package do
begin
system "jsl -nofilelisting -nologo -conf docs/jsl.conf -process lifecycle.js"
minimize_with_header('lifecycle.js', 'lifecycle-min.js')
minimize_with_header('lifecycle.js', 'lifecycle.min.js')
check 'docco', 'docco', 'https://github.com/jashkenas/docco'
sh "docco lifecycle.js"
end
Expand Down
File renamed without changes.

0 comments on commit 5ecdbeb

Please sign in to comment.