motion_bindable 0.2.0 → 0.2.1

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: 4a89a39aab018219f267f3eff32cde82ac521544
4
- data.tar.gz: 1447ebff62c07174943bb0cb3bf30c48794b8267
3
+ metadata.gz: 5d4f78823ed3a1224388b7fc633d184c2b946722
4
+ data.tar.gz: a480c9b6b1c83b6e02a6189155577d27e42057ab
5
5
  SHA512:
6
- metadata.gz: 3bccfc36a62b72c7fe972263f465ea6b14985a215077f51018ffdc1d99e336097f5e0d21b126ccdd276d7862ce154d3c57c1aaeb43e21e86d4e461e27baa4b72
7
- data.tar.gz: 256257f81086382161edc6b8462d4129946628cd0d801128be7b26f2802f92c098e926c4aa6e29ef36c65db67e8ba6e47c8a12ea4130dc0b615989777598a59f
6
+ metadata.gz: be68505282ce2472d12ab56f3d0eb82591ede10e86e0b0e7f2684f1a11858fd115ea23b3751ab5a1aef089828e15b1bfa2c40eb275f6929e8c22484addb541bc
7
+ data.tar.gz: 85eb9ab70b26840aec2ee26fb627a87ab1904c914fbe596dde9f29d78893399b5dc56fca6da3fe7697bcff51c494a010934e31c4aa674f73ce86e89f3c3970cd
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/nathankot/motion-bindable.png?branch=master)](https://travis-ci.org/nathankot/motion-bindable)
4
4
  [![Code Climate](https://codeclimate.com/github/nathankot/motion-bindable.png)](https://codeclimate.com/github/nathankot/motion-bindable)
5
5
 
6
- A simple data binding library for RubyMotion.
6
+ A simple two-way data binding library for RubyMotion.
7
7
 
8
8
  ## Installation
9
9
 
@@ -29,6 +29,14 @@ def application(application, didFinishLaunchingWithOptions: launch_options)
29
29
  end
30
30
  ```
31
31
 
32
+ ## Terminology
33
+
34
+ | Name | Definition |
35
+ | --- | --- |
36
+ | Object | Refers to the _parent_ object that can have many bindings. Usually a model of some sort. |
37
+ | Binding | The connection between an object and it's bound children. Observes and updates both sides. Represented as a `Strategy` |
38
+ | Bound | Usually an _input_ object, like a `UITextField` or a `Proc`. |
39
+
32
40
  ## Usage
33
41
 
34
42
  Add `include MotionBindable::Bindable` to make an object bindable:
@@ -86,7 +94,7 @@ comes with MotionBindable. Take a look in `lib/motion_bindable/strategies` for
86
94
  the available defaults. You can implement your own strategies by extending
87
95
  `MotionBindable::Strategy`. Please use the existing strategies as a guideline.
88
96
 
89
- ### Defaults Strategies
97
+ ### Default Strategies
90
98
 
91
99
  The following strategies come with motion-bindable and are setup when
92
100
  `MotionBindable::Strategies.use` is called.
@@ -44,7 +44,7 @@ module MotionBindable
44
44
  end
45
45
 
46
46
  def unbind
47
- @watch_bound, @watch_object = nil
47
+ @watching = nil
48
48
  end
49
49
 
50
50
  private # Methods to leave alone
@@ -70,30 +70,27 @@ module MotionBindable
70
70
  end
71
71
 
72
72
  def start_listen
73
+ sides = []
74
+
73
75
  if respond_to?(:start_observing_bound) then start_observing_bound
74
76
  elsif respond_to?(:refresh_bound) && respond_to?(:on_bound_change)
75
- watch_bound
77
+ sides << :bound
76
78
  end
77
-
78
79
  if respond_to?(:start_observing_object) then start_observing_object
79
80
  elsif respond_to?(:refresh_object) && respond_to?(:on_object_change)
80
- watch_object
81
+ sides << object
81
82
  end
82
- end
83
83
 
84
- def watch_bound
85
- @watch_bound = dispatcher.async do
86
- result = refresh_bound
87
- on_bound_change(result) if result
88
- dispatcher.after(WATCH_TICK) { watch_bound } unless @watch_bound
89
- end
84
+ watch(sides)
90
85
  end
91
86
 
92
- def watch_object
93
- @watch_object = dispatcher.async do
94
- result = refresh_object
95
- on_object_change(result) if result
96
- dispatcher.after(WATCH_TICK) { watch_object } unless @watch_object
87
+ def watch(sides)
88
+ @watching = dispatcher.async do
89
+ bound_result = refresh_bound if sides.include?(:bound)
90
+ object_result = refresh_object if sides.include?(:object)
91
+ on_bound_change(bound_result) if bound_result
92
+ on_object_change(object_result) if object_result
93
+ dispatcher.after(WATCH_TICK) { watch(sides) } unless @watching
97
94
  end
98
95
  end
99
96
 
@@ -1,3 +1,3 @@
1
1
  module MotionBindable
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion_bindable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Kot