Class: RMXFirebaseListener
- Inherits:
-
Object
- Object
- RMXFirebaseListener
- Includes:
- RMXCommonMethods
- Defined in:
- lib/motion/RMXFirebaseListener.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#handle ⇒ Object
Returns the value of attribute handle.
-
#ref ⇒ Object
Returns the value of attribute ref.
-
#snapshot ⇒ Object
Returns the value of attribute snapshot.
-
#value_required ⇒ Object
Returns the value of attribute value_required.
Instance Method Summary collapse
- #attr(keypath) ⇒ Object
- #cancelled? ⇒ Boolean
- #hasValue? ⇒ Boolean
- #ready? ⇒ Boolean
- #rmx_dealloc ⇒ Object
- #start! ⇒ Object
- #stop! ⇒ Object
- #toValue ⇒ Object
- #valueForKey(key) ⇒ Object
- #valueForUndefinedKey(key) ⇒ Object
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
5 6 7 |
# File 'lib/motion/RMXFirebaseListener.rb', line 5 def callback @callback end |
#handle ⇒ Object
Returns the value of attribute handle.
5 6 7 |
# File 'lib/motion/RMXFirebaseListener.rb', line 5 def handle @handle end |
#ref ⇒ Object
Returns the value of attribute ref.
5 6 7 |
# File 'lib/motion/RMXFirebaseListener.rb', line 5 def ref @ref end |
#snapshot ⇒ Object
Returns the value of attribute snapshot.
5 6 7 |
# File 'lib/motion/RMXFirebaseListener.rb', line 5 def snapshot @snapshot end |
#value_required ⇒ Object
Returns the value of attribute value_required.
5 6 7 |
# File 'lib/motion/RMXFirebaseListener.rb', line 5 def value_required @value_required end |
Instance Method Details
#attr(keypath) ⇒ Object
64 65 66 |
# File 'lib/motion/RMXFirebaseListener.rb', line 64 def attr(keypath) valueForKeyPath(keypath) end |
#cancelled? ⇒ Boolean
18 19 20 |
# File 'lib/motion/RMXFirebaseListener.rb', line 18 def cancelled? !!@cancelled end |
#hasValue? ⇒ Boolean
56 57 58 |
# File 'lib/motion/RMXFirebaseListener.rb', line 56 def hasValue? !!(snapshot && snapshot.hasValue?) end |
#ready? ⇒ Boolean
14 15 16 |
# File 'lib/motion/RMXFirebaseListener.rb', line 14 def ready? !!@ready end |
#rmx_dealloc ⇒ Object
8 9 10 11 12 |
# File 'lib/motion/RMXFirebaseListener.rb', line 8 def rmx_dealloc if ref && handle ref.off(handle) end end |
#start! ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/motion/RMXFirebaseListener.rb', line 22 def start! RMX(self).require_queue!(RMXFirebase::QUEUE, __FILE__, __LINE__) if RMX::DEBUG_QUEUES cancel_block = lambda do |err| @cancelled = err RMX(self).trigger(:cancelled, self) RMX(self).trigger(:finished, self) end @handle = ref.on(:value, { :disconnect => cancel_block }) do |snap| RMXFirebase::QUEUE. do @snapshot = snap if value_required && !snap.hasValue? cancel_block.call(NSError.errorWithDomain("requirement failure", code:0, userInfo:{ :error => "requirement_failure" })) else callback.call(snap) if callback && callback_owner @ready = true RMX(self).trigger(:ready, self) RMX(self).trigger(:finished, self) # p "ready__" end end end end |
#stop! ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/motion/RMXFirebaseListener.rb', line 47 def stop! RMX(self).require_queue!(RMXFirebase::QUEUE, __FILE__, __LINE__) if RMX::DEBUG_QUEUES @cancelled = false @ready = false if ref && handle ref.off(handle) end end |
#toValue ⇒ Object
60 61 62 |
# File 'lib/motion/RMXFirebaseListener.rb', line 60 def toValue snapshot && snapshot.value end |
#valueForKey(key) ⇒ Object
68 69 70 |
# File 'lib/motion/RMXFirebaseListener.rb', line 68 def valueForKey(key) snapshot && snapshot.valueForKey(key) end |
#valueForUndefinedKey(key) ⇒ Object
72 73 74 |
# File 'lib/motion/RMXFirebaseListener.rb', line 72 def valueForUndefinedKey(key) nil end |