Class: Google::Cloud::Firestore::DocumentListener
- Inherits:
-
Object
- Object
- Google::Cloud::Firestore::DocumentListener
- Includes:
- MonitorMixin
- Defined in:
- lib/google/cloud/firestore/document_listener.rb
Overview
DocumentListener
An ongoing listen operation on a document reference. This is returned by calling Google::Cloud::Firestore::DocumentReference#listen.
Instance Method Summary collapse
-
#last_error ⇒ Exception?
The most recent unhandled error to occur while listening for changes.
-
#on_error {|callback| ... } ⇒ Object
Register to be notified of errors when raised.
-
#stop ⇒ Object
Stops the client listening for changes.
-
#stopped? ⇒ Boolean
Whether the client has stopped listening for changes.
Instance Method Details
#last_error ⇒ Exception?
The most recent unhandled error to occur while listening for changes.
If an unhandled error has occurred the listener will attempt to recover from the error and resume listening.
189 190 191 |
# File 'lib/google/cloud/firestore/document_listener.rb', line 189 def last_error synchronize { @last_error } end |
#on_error {|callback| ... } ⇒ Object
Register to be notified of errors when raised.
If an unhandled error has occurred the listener will attempt to recover from the error and resume listening.
Multiple error handlers can be added.
158 159 160 161 |
# File 'lib/google/cloud/firestore/document_listener.rb', line 158 def on_error &block raise ArgumentError, "on_error must be called with a block" unless block_given? synchronize { @error_callbacks << block } end |
#stop ⇒ Object
Stops the client listening for changes.
95 96 97 |
# File 'lib/google/cloud/firestore/document_listener.rb', line 95 def stop @listener.stop end |
#stopped? ⇒ Boolean
Whether the client has stopped listening for changes.
123 124 125 |
# File 'lib/google/cloud/firestore/document_listener.rb', line 123 def stopped? @listener.stopped? end |