Permalink
Browse files

Updated README. Moved min version to '.min' convention.

  • Loading branch information...
1 parent d01eafd commit 5ecdbeb490757f7e0c7225c22a4546e476a2581f Kevin Malakoff committed Nov 18, 2011
Showing with 40 additions and 9 deletions.
  1. +38 −7 README.md
  2. +2 −2 Rakefile
  3. 0 lifecycle-min.js → lifecycle.min.js
View
@@ -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()
@@ -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:
View
@@ -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
File renamed without changes.

0 comments on commit 5ecdbeb

Please sign in to comment.