Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improved documentation for managed instances

  • Loading branch information...
commit 2fd92680733333af210cae273d2cfb666d71e262 1 parent 8b2dc34
Emerson Macedo authored December 13, 2011

Showing 1 changed file with 8 additions and 2 deletions. Show diff stats Hide diff stats

  1. 10  Readme.md
10  Readme.md
Source Rendered
@@ -30,20 +30,26 @@ stopwatch.on('end', function() {
30 30
 ```
31 31
 
32 32
 ### Managed
33  
-If you want a managed instance you only need to require the module and use the get function.
  33
+If you want a managed instance (per identifier) you only need to require the module and use the get function.
34 34
 
35 35
 ```js
36 36
 var StopwatchManager = require('stopwatch');
37 37
 
38  
-var stopwatch = StopwatchManager.get(1, {seconds: 1 });
  38
+var stopwatch = StopwatchManager.get(1, {seconds: 10 });
39 39
 stopwatch.on('tick', function(secondsLeft) {
40 40
   //when one second pass.
41 41
 });
42 42
 stopwatch.on('end', function() {
43 43
    //when the time ends
  44
+   //StopwatchManager also destroys the managed hash reference
44 45
 });
  46
+
  47
+//It will get the same instance
  48
+var stopwatchRecovered = StopwatchManager.get(1, {seconds: 10 });
45 49
 ```
46 50
 
  51
+If you invoke get with the same id, it will not create another instance, but use the same stored instance. When ends, it cleans the managed reference to prevent memory leaks by strong references.
  52
+
47 53
 ### Examples
48 54
 See the test folder. I'll write more example in a examples folder.
49 55
 

0 notes on commit 2fd9268

Please sign in to comment.
Something went wrong with that request. Please try again.