asynchronizer 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3677b8551554d4fc3fce659e43593b91c753c489
4
- data.tar.gz: b3769c88d740291dc0656d7fc40c3bb4aa33351a
3
+ metadata.gz: 52da27ccc15215f7011b301faeb3f2b868db92fc
4
+ data.tar.gz: f633668ba2bd93e7f0577c1fb0493ecff2c327db
5
5
  SHA512:
6
- metadata.gz: 55a1f64422a1df2ba6b3f0fd0d6fd4321d00d1fd2105cdd17871e82e5210791edcc05b85c6109704c970f1d846f5a3d12217883581fd7759803d5ffa53a59ac4
7
- data.tar.gz: 1244c06448c04cb648fca7f6d571c72e8542cd0e4df57dda7160bfcb3056bd023f302a247fbb4be939153550dedd467731a5facf60d882d3f507a4fe17c50958
6
+ metadata.gz: edf988b288ba471a6c1c93eb53cde80b76d4561e8bdfa6c367752a789376c602f4902a5c0506231c69ce2fa98226309552d6587b10c430f38987e25ceab11ea8
7
+ data.tar.gz: d2a7d32b3c856b7d6b071fe37699d8e4999105ddf3e6683ac4a6679cdf5aa2055143cd0af037d04c8b6fa1197f45acfc8f4be30b10e243506be4d935863c0191
@@ -1,3 +1,3 @@
1
1
  module Asynchronizer
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,14 +1,12 @@
1
1
  # Collects data from asynchronous events.
2
2
 
3
- class window.Asynchronizer
3
+ class Asynchronizer
4
4
 
5
- # conditions: array of simple conditions to wait for.
6
- # callback: method that is called when all required conditions are met.
7
- # Provides the collected data.
8
- constructor: (conditions, callback) ->
5
+ # conditions: Array of simple conditions to wait for.
6
+ constructor: (conditions) ->
9
7
 
10
8
  # The callback to call when all conditions are fulfilled.
11
- @callback = callback
9
+ @callback = undefined
12
10
 
13
11
  # The conditions that still need to be fulfilled before we are done
14
12
  # and can call the callback.
@@ -22,5 +20,17 @@ class window.Asynchronizer
22
20
  check: (condition, value) ->
23
21
  @values.push value if value
24
22
  @remaining_conditions = _.without @remaining_conditions, condition
25
- if @remaining_conditions.length is 0
23
+ @_check_and_fire_conditions()
24
+
25
+
26
+ # Checks the conditions and fires them if this is the time.
27
+ _check_and_fire_conditions: ->
28
+ if @remaining_conditions.length is 0 and @callback
26
29
  @callback @values
30
+
31
+
32
+ # Sets the callback to be called when done.
33
+ then: (callback) ->
34
+ @callback = callback
35
+ @_check_and_fire_conditions()
36
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asynchronizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Goslar