motion_bindable 0.0.4 → 0.0.5

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: 29efca7dd615f1582075cf3024ba561063f6c2d7
4
- data.tar.gz: c9d7c8f83b816b132a678b3990560dfde9859254
3
+ metadata.gz: a486b5fc2ec81e0ef4841750fb42220cd7c2cb39
4
+ data.tar.gz: 5b13fb6be0618081aa9691d390dbcd81de960bc9
5
5
  SHA512:
6
- metadata.gz: 3efaa8e1c0406d8563afc01027e5ba2cea1b73a2ab1b07521b4ca62360643a18d261cfe13886aa729d15f2923e8e975c00b82c1d7b8f0000fd6ea1557f58232f
7
- data.tar.gz: a32760942935f0bcfc9208992954d592fdf15ad027ca348d39661e35c1ef863abdd4b37dd10ab195e776d423dabb8763a4b441683061874f2cc3c071fbedba60
6
+ metadata.gz: 12bbb1bea61395a835c5e978b7b5600aa3a1c10cbdee35e4728fd8b23e8a64c0662547b5f9c1b34e6208815267c8365ad5219b4a530502c09c0c4ea44a92230c
7
+ data.tar.gz: 28383e50488353a5be93ca34a8dc47d8a7a3543042a116daa8a644a94300e55045f95a414d9f2a92a2b11edadb917bdbca6bf5c757221ea4ba3df4b3d4d0272f
@@ -22,7 +22,7 @@ module MotionBindable
22
22
 
23
23
  def initialize(object, attribute)
24
24
  @attribute = attribute.to_sym
25
- self.object = object
25
+ self.object = WeakRef.new(object)
26
26
  end
27
27
 
28
28
  def bind(bound)
@@ -1,3 +1,3 @@
1
1
  module MotionBindable
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -3,19 +3,16 @@ module MotionBindable::Strategies
3
3
  class UITextField < ::MotionBindable::Strategy
4
4
 
5
5
  def on_bind
6
- if bound.delegate.is_a? ::MotionBindable::DelegateProxy
7
- bound.delegate.delegates << self
8
- else
9
- bound.delegate = ::MotionBindable::DelegateProxy.new(
10
- bound.delegate,
11
- self
12
- )
13
- end
14
-
15
6
  update_attribute
7
+ NSNotificationCenter.defaultCenter.addObserver(
8
+ self,
9
+ selector: :on_change,
10
+ name: UITextFieldTextDidChangeNotification,
11
+ object: bound
12
+ )
16
13
  end
17
14
 
18
- def textFieldDidEndEditing(_)
15
+ def on_change
19
16
  update_attribute
20
17
  end
21
18
 
@@ -47,7 +47,10 @@ describe 'MotionBindable::Strategies::UITextField' do
47
47
 
48
48
  before do
49
49
  @text_field.text = 'Updated.'
50
- @text_field.delegate.textFieldDidEndEditing(self)
50
+ NSNotificationCenter.defaultCenter.postNotificationName(
51
+ UITextFieldTextDidChangeNotification,
52
+ object: @text_field
53
+ )
51
54
  end
52
55
 
53
56
  it 'should update the root attribute' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion_bindable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Kot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-14 00:00:00.000000000 Z
11
+ date: 2013-12-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple data binding library for RubyMotion.
14
14
  email:
@@ -27,7 +27,6 @@ files:
27
27
  - app/app_delegate.rb
28
28
  - lib/motion_bindable.rb
29
29
  - lib/motion_bindable/bindable.rb
30
- - lib/motion_bindable/delegate_proxy.rb
31
30
  - lib/motion_bindable/strategy.rb
32
31
  - lib/motion_bindable/version.rb
33
32
  - lib/strategies/proc.rb
@@ -1,23 +0,0 @@
1
- module MotionBindable
2
-
3
- # This allows objects to register multiple delegates
4
- class DelegateProxy
5
-
6
- attr_accessor :delegates
7
-
8
- def initialize(*initial_delegates)
9
- self.delegates = initial_delegates
10
- end
11
-
12
- def method_missing(name, *args, &block)
13
- responses = []
14
- delegates.each do |delegate|
15
- responses << delegate.send(name, *args, &block) if delegate.respond_to?(name)
16
- end
17
-
18
- responses.first
19
- end
20
-
21
- end
22
-
23
- end