diff --git a/src/shared_types.rs b/src/shared_types.rs index 99662b0..4847718 100644 --- a/src/shared_types.rs +++ b/src/shared_types.rs @@ -46,7 +46,7 @@ impl DefaultPyErr for IntegratedOperationException { #[pyclass] #[derive(Clone)] -pub struct PyOrigin(pub Origin); +pub struct ObservationId(pub Origin); #[derive(Clone)] pub enum CompatiblePyType<'a> { diff --git a/src/y_array.rs b/src/y_array.rs index 1faf74c..feb107a 100644 --- a/src/y_array.rs +++ b/src/y_array.rs @@ -1,6 +1,6 @@ use crate::json_builder::JsonBuilder; use crate::shared_types::{ - CompatiblePyType, DefaultPyErr, PreliminaryObservationException, PyOrigin, TypeWithDoc, + CompatiblePyType, DefaultPyErr, ObservationId, PreliminaryObservationException, TypeWithDoc, }; use crate::type_conversions::{events_into_py, WithDocToPython}; use crate::y_doc::{WithDoc, YDocInner}; @@ -364,8 +364,8 @@ impl YArray { /// Subscribes to all operations happening over this instance of `YArray`. All changes are /// batched and eventually triggered during transaction commit phase. - /// Returns a `PyOrigin` which can be used to cancel the callback with `unobserve`. - pub fn observe(&mut self, f: PyObject) -> PyResult { + /// Returns a `ObservationId` which can be used to cancel the callback with `unobserve`. + pub fn observe(&mut self, f: PyObject) -> PyResult { match &mut self.0 { SharedType::Integrated(array) => { let doc = array.doc.clone(); @@ -378,13 +378,13 @@ impl YArray { } }) }); - Ok(PyOrigin(origin)) + Ok(ObservationId(origin)) } SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } /// Observes YArray events and events of all child elements. - pub fn observe_deep(&mut self, f: PyObject) -> PyResult { + pub fn observe_deep(&mut self, f: PyObject) -> PyResult { match &mut self.0 { SharedType::Integrated(array) => { let doc = array.doc.clone(); @@ -399,24 +399,24 @@ impl YArray { } }) }); - Ok(PyOrigin(origin)) + Ok(ObservationId(origin)) } SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } - /// Cancels the callback of an observer using the `sub_id` returned from the `observe` method. - pub fn unobserve(&mut self, origin: PyOrigin) -> PyResult { + /// Cancels the callback of an observer using the `observation_d` returned from the `observe` method. + pub fn unobserve(&mut self, observation_d: ObservationId) -> PyResult { match &mut self.0 { - SharedType::Integrated(arr) => Ok(arr.unobserve(Origin::from(origin.0))), + SharedType::Integrated(arr) => Ok(arr.unobserve(observation_d.0)), SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } - /// Cancels the callback of an observer using the `sub_id` returned from the `observe_deep` method. - pub fn unobserve_deep(&mut self, origin: PyOrigin) -> PyResult { + /// Cancels the callback of an observer using the `observation_d` returned from the `observe_deep` method. + pub fn unobserve_deep(&mut self, observation_d: ObservationId) -> PyResult { match &mut self.0 { - SharedType::Integrated(arr) => Ok(arr.unobserve_deep(Origin::from(origin.0))), + SharedType::Integrated(arr) => Ok(arr.unobserve_deep(observation_d.0)), SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } diff --git a/src/y_doc.rs b/src/y_doc.rs index 2edec04..904090b 100644 --- a/src/y_doc.rs +++ b/src/y_doc.rs @@ -2,7 +2,7 @@ use std::cell::RefCell; use std::rc::Rc; use std::rc::Weak; -use crate::shared_types::PyOrigin; +use crate::shared_types::ObservationId; use crate::y_array::YArray; use crate::y_map::YMap; use crate::y_text::YText; @@ -282,7 +282,7 @@ impl YDoc { } /// Subscribes a callback to a `YDoc` lifecycle event. - pub fn observe_after_transaction(&mut self, callback: PyObject) -> PyOrigin { + pub fn observe_after_transaction(&mut self, callback: PyObject) -> ObservationId { let origin = Origin::from(uuid_v4().to_string()); self.0 .borrow() @@ -296,7 +296,7 @@ impl YDoc { }) }) .unwrap(); - PyOrigin(origin) + ObservationId(origin) } } diff --git a/src/y_map.rs b/src/y_map.rs index b5a08a8..a061d63 100644 --- a/src/y_map.rs +++ b/src/y_map.rs @@ -14,7 +14,7 @@ use yrs::{uuid_v4, Map, MapRef, Observable, Origin, TransactionMut}; use crate::json_builder::JsonBuilder; use crate::shared_types::{ - DefaultPyErr, PreliminaryObservationException, PyOrigin, SharedType, TypeWithDoc, + DefaultPyErr, ObservationId, PreliminaryObservationException, SharedType, TypeWithDoc, }; use crate::type_conversions::{events_into_py, PyObjectWrapper, ToPython, WithDocToPython}; use crate::y_doc::{WithDoc, YDocInner}; @@ -261,7 +261,7 @@ impl YMap { ValueView::new(self) } - pub fn observe(&mut self, f: PyObject) -> PyResult { + pub fn observe(&mut self, f: PyObject) -> PyResult { match &mut self.0 { SharedType::Integrated(v) => { let doc = v.doc.clone(); @@ -275,13 +275,13 @@ impl YMap { } }) }); - Ok(PyOrigin(origin)) + Ok(ObservationId(origin)) } SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } - pub fn observe_deep(&mut self, f: PyObject) -> PyResult { + pub fn observe_deep(&mut self, f: PyObject) -> PyResult { match &mut self.0 { SharedType::Integrated(map) => { let doc = map.doc.clone(); @@ -295,24 +295,24 @@ impl YMap { } }) }); - Ok(PyOrigin(origin)) + Ok(ObservationId(origin)) } SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } - /// Cancels the observer callback associated with the `sub_id` returned from the `observe` method. - pub fn unobserve(&mut self, origin: PyOrigin) -> PyResult { + /// Cancels the observer callback associated with the `observation_id` returned from the `observe` method. + pub fn unobserve(&mut self, observation_id: ObservationId) -> PyResult { match &mut self.0 { - SharedType::Integrated(map) => Ok(map.unobserve(Origin::from(origin.0))), + SharedType::Integrated(map) => Ok(map.unobserve(observation_id.0)), SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } - /// Cancels the observer callback associated with the `sub_id` returned from the `observe_deep` method. - pub fn unobserve_deep(&mut self, origin: PyOrigin) -> PyResult { + /// Cancels the observer callback associated with the `observation_id` returned from the `observe_deep` method. + pub fn unobserve_deep(&mut self, observation_id: ObservationId) -> PyResult { match &mut self.0 { - SharedType::Integrated(map) => Ok(map.unobserve_deep(Origin::from(origin.0))), + SharedType::Integrated(map) => Ok(map.unobserve_deep(observation_id.0)), SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } diff --git a/src/y_text.rs b/src/y_text.rs index 344d4cf..4867f4b 100644 --- a/src/y_text.rs +++ b/src/y_text.rs @@ -1,6 +1,6 @@ use crate::shared_types::{ - CompatiblePyType, DefaultPyErr, IntegratedOperationException, PreliminaryObservationException, - PyOrigin, SharedType, TypeWithDoc, + CompatiblePyType, DefaultPyErr, IntegratedOperationException, ObservationId, + PreliminaryObservationException, SharedType, TypeWithDoc, }; use crate::type_conversions::{events_into_py, ToPython, WithDocToPython}; use crate::y_doc::{WithDoc, YDocInner}; @@ -237,7 +237,7 @@ impl YText { } /// Observes updates from the `YText` instance. - pub fn observe(&mut self, f: PyObject) -> PyResult { + pub fn observe(&mut self, f: PyObject) -> PyResult { match &mut self.0 { SharedType::Integrated(text) => { let doc = text.doc.clone(); @@ -250,14 +250,14 @@ impl YText { } }); }); - Ok(PyOrigin(origin)) + Ok(ObservationId(origin)) } SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } /// Observes updates from the `YText` instance and all of its nested children. - pub fn observe_deep(&mut self, f: PyObject) -> PyResult { + pub fn observe_deep(&mut self, f: PyObject) -> PyResult { match &mut self.0 { SharedType::Integrated(text) => { let doc = text.doc.clone(); @@ -271,24 +271,24 @@ impl YText { } }) }); - Ok(PyOrigin(origin)) + Ok(ObservationId(origin)) } SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } - /// Cancels the observer callback associated with the `sub_id` returned from the `observe` method. - pub fn unobserve(&mut self, origin: PyOrigin) -> PyResult { + /// Cancels the observer callback associated with the `observation_id` returned from the `observe` method. + pub fn unobserve(&mut self, observation_id: ObservationId) -> PyResult { match &mut self.0 { - SharedType::Integrated(text) => Ok(text.unobserve(Origin::from(origin.0))), + SharedType::Integrated(text) => Ok(text.unobserve(observation_id.0)), SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } - /// Cancels the observer callback associated with the `sub_id` returned from the `observe_deep` method. - pub fn unobserve_deep(&mut self, origin: PyOrigin) -> PyResult { + /// Cancels the observer callback associated with the `observation_id` returned from the `observe_deep` method. + pub fn unobserve_deep(&mut self, observation_id: ObservationId) -> PyResult { match &mut self.0 { - SharedType::Integrated(text) => Ok(text.unobserve_deep(Origin::from(origin.0))), + SharedType::Integrated(text) => Ok(text.unobserve_deep(observation_id.0)), SharedType::Prelim(_) => Err(PreliminaryObservationException::default_message()), } } diff --git a/src/y_xml.rs b/src/y_xml.rs index 509b12f..9af9eaa 100644 --- a/src/y_xml.rs +++ b/src/y_xml.rs @@ -1,4 +1,4 @@ -use crate::shared_types::{PyOrigin, TypeWithDoc}; +use crate::shared_types::{ObservationId, TypeWithDoc}; use crate::y_doc::{WithDoc, YDocInner}; use pyo3::prelude::*; use pyo3::types::{PyDict, PyList}; @@ -219,8 +219,8 @@ impl YXmlElement { /// Subscribes to all operations happening over this instance of `YXmlElement`. All changes are /// batched and eventually triggered during transaction commit phase. - /// Returns an `PyOrigin` which, can be used to unsubscribe the observer. - pub fn observe(&mut self, f: PyObject) -> PyOrigin { + /// Returns an `ObservationId` which, can be used to unsubscribe the observer. + pub fn observe(&mut self, f: PyObject) -> ObservationId { let doc = self.0.doc.clone(); let origin = Origin::from(uuid_v4().to_string()); self.0.observe_with(origin.clone(), move |txn, e| { @@ -231,13 +231,13 @@ impl YXmlElement { } }) }); - PyOrigin(origin) + ObservationId(origin) } /// Subscribes to all operations happening over this instance of `YXmlElement` and all of its children. /// All changes are batched and eventually triggered during transaction commit phase. - /// Returns an `PyOrigin` which, can be used to unsubscribe the observer. - pub fn observe_deep(&mut self, f: PyObject) -> PyOrigin { + /// Returns an `ObservationId` which, can be used to unsubscribe the observer. + pub fn observe_deep(&mut self, f: PyObject) -> ObservationId { let doc = self.0.doc.clone(); let origin = Origin::from(uuid_v4().to_string()); self.0 @@ -250,17 +250,17 @@ impl YXmlElement { } }) }); - PyOrigin(origin) + ObservationId(origin) } - /// Cancels the observer callback associated with the `origin` returned from the `observe` method. - pub fn unobserve(&mut self, origin: PyOrigin) -> bool { - self.0.unobserve(origin.0) + /// Cancels the observer callback associated with the `observation_id` returned from the `observe` method. + pub fn unobserve(&mut self, observation_id: ObservationId) -> bool { + self.0.unobserve(observation_id.0) } - /// Cancels the observer callback associated with the `origin` returned from the `observe_deep` method. - pub fn unobserve_deep(&mut self, origin: PyOrigin) -> bool { - self.0.unobserve_deep(origin.0) + /// Cancels the observer callback associated with the `observation_id` returned from the `observe_deep` method. + pub fn unobserve_deep(&mut self, observation_id: ObservationId) -> bool { + self.0.unobserve_deep(observation_id.0) } } @@ -419,8 +419,8 @@ impl YXmlText { /// Subscribes to all operations happening over this instance of `YXmlText`. All changes are /// batched and eventually triggered during transaction commit phase. - /// Returns an `PyOrigin` which, which can be used to unsubscribe the callback function. - pub fn observe(&mut self, f: PyObject) -> PyOrigin { + /// Returns an `ObservationId` which, which can be used to unsubscribe the callback function. + pub fn observe(&mut self, f: PyObject) -> ObservationId { let doc = self.0.doc.clone(); let origin = Origin::from(uuid_v4().to_string()); self.0.observe_with(origin.clone(), move |txn, e| { @@ -431,13 +431,13 @@ impl YXmlText { } }) }); - PyOrigin(origin) + ObservationId(origin) } /// Subscribes to all operations happening over this instance of `YXmlText` and its child elements. All changes are /// batched and eventually triggered during transaction commit phase. - /// Returns an `Origin` which, which can be used to unsubscribe the callback function. - pub fn observe_deep(&mut self, f: PyObject) -> PyOrigin { + /// Returns an `ObservationId` which, which can be used to unsubscribe the callback function. + pub fn observe_deep(&mut self, f: PyObject) -> ObservationId { let doc = self.0.doc.clone(); let origin = Origin::from(uuid_v4().to_string()); self.0 @@ -449,17 +449,17 @@ impl YXmlText { } }) }); - PyOrigin(origin) + ObservationId(origin) } - /// Cancels the observer callback associated with the `origin` returned from the `observe` method. - pub fn unobserve(&mut self, origin: PyOrigin) -> bool { - self.0.unobserve(origin.0) + /// Cancels the observer callback associated with the `observation_id` returned from the `observe` method. + pub fn unobserve(&mut self, observation_id: ObservationId) -> bool { + self.0.unobserve(observation_id.0) } - /// Cancels the observer callback associated with the `origin` returned from the `observe_deep` method. - pub fn unobserve_deep(&mut self, origin: PyOrigin) -> bool { - self.0.unobserve_deep(origin.0) + /// Cancels the observer callback associated with the `observation_id` returned from the `observe_deep` method. + pub fn unobserve_deep(&mut self, observation_id: ObservationId) -> bool { + self.0.unobserve_deep(observation_id.0) } } @@ -581,8 +581,8 @@ impl YXmlFragment { /// Subscribes to all operations happening over this instance of `YXmlElement`. All changes are /// batched and eventually triggered during transaction commit phase. - /// Returns an `PyOrigin` which, can be used to unsubscribe the observer. - pub fn observe(&mut self, f: PyObject) -> PyOrigin { + /// Returns an `ObservationId` which, can be used to unsubscribe the observer. + pub fn observe(&mut self, f: PyObject) -> ObservationId { let doc = self.0.doc.clone(); let origin = Origin::from(uuid_v4().to_string()); self.0.observe_with(origin.clone(), move |txn, e| { @@ -593,13 +593,13 @@ impl YXmlFragment { } }) }); - PyOrigin(origin) + ObservationId(origin) } /// Subscribes to all operations happening over this instance of `YXmlElement` and all of its children. /// All changes are batched and eventually triggered during transaction commit phase. - /// Returns an `PyOrigin` which, can be used to unsubscribe the observer. - pub fn observe_deep(&mut self, f: PyObject) -> PyOrigin { + /// Returns an `ObservationId` which, can be used to unsubscribe the observer. + pub fn observe_deep(&mut self, f: PyObject) -> ObservationId { let doc = self.0.doc.clone(); let origin = Origin::from(uuid_v4().to_string()); self.0 @@ -612,17 +612,17 @@ impl YXmlFragment { } }) }); - PyOrigin(origin) + ObservationId(origin) } - /// Cancels the observer callback associated with the `origin` returned from the `observe` method. - pub fn unobserve(&mut self, origin: PyOrigin) -> bool { - self.0.unobserve(origin.0) + /// Cancels the observer callback associated with the `observation_id` returned from the `observe` method. + pub fn unobserve(&mut self, observation_id: ObservationId) -> bool { + self.0.unobserve(observation_id.0) } - /// Cancels the observer callback associated with the `origin` returned from the `observe_deep` method. - pub fn unobserve_deep(&mut self, origin: PyOrigin) -> bool { - self.0.unobserve_deep(origin.0) + /// Cancels the observer callback associated with the `observation_id` returned from the `observe_deep` method. + pub fn unobserve_deep(&mut self, observation_id: ObservationId) -> bool { + self.0.unobserve_deep(observation_id.0) } /// Retrieves a value stored at a given `index`. Returns `None` when provided index was out diff --git a/tests/test_y_array.py b/tests/test_y_array.py index f2a4512..930add2 100644 --- a/tests/test_y_array.py +++ b/tests/test_y_array.py @@ -196,7 +196,7 @@ def callback(e: YArrayEvent): target = e.target delta = e.delta - subscription_id = x.observe(callback) + observation_id = x.observe(callback) # insert initial data to an empty YArray with d1.begin_transaction() as txn: @@ -226,7 +226,7 @@ def callback(e: YArrayEvent): delta = None # Cancel the observer and make sure that callback is no longer called - x.unobserve(subscription_id) + x.unobserve(observation_id) with d1.begin_transaction() as txn: x.insert(txn, 1, 6) diff --git a/tests/test_y_map.py b/tests/test_y_map.py index 88359f5..2d34a6b 100644 --- a/tests/test_y_map.py +++ b/tests/test_y_map.py @@ -199,7 +199,7 @@ def callback(e: YMapEvent): target = e.target entries = e.keys - subscription_id = x.observe(callback) + observation_id = x.observe(callback) # insert initial data to an empty YMap with d1.begin_transaction() as txn: @@ -230,7 +230,7 @@ def callback(e: YMapEvent): entries = None # free the observer and make sure that callback is no longer called - x.unobserve(subscription_id) + x.unobserve(observation_id) with d1.begin_transaction() as txn: x.set(txn, "key1", [6]) assert target == None diff --git a/tests/test_y_text.py b/tests/test_y_text.py index f1af284..59dffff 100644 --- a/tests/test_y_text.py +++ b/tests/test_y_text.py @@ -77,7 +77,7 @@ def callback(e: YTextEvent): x = d1.get_text("test") - subscription_id = x.observe(callback) + observation_id = x.observe(callback) # insert initial data to an empty YText with d1.begin_transaction() as txn: @@ -107,14 +107,14 @@ def callback(e: YTextEvent): delta = None # free the observer and make sure that callback is no longer called - x.unobserve(subscription_id) + x.unobserve(observation_id) with d1.begin_transaction() as txn: x.insert(txn, 1, "fgh") assert target == None assert delta == None -def test_drop_sub_id(): +def test_drop_observation_id(): d = Y.YDoc() target = None delta = None @@ -128,7 +128,7 @@ def callback(e): x = d.get_text("test") def register_callback(x, callback): - # The subscription_id `i` is dropped here + # The observation_id `i` is dropped here i = x.observe(callback) register_callback(x, callback) @@ -219,7 +219,7 @@ def callback(e): assert events is not None and len(events) == 1 - # verify that the subscription drops + # verify that the observation drops events = None text.unobserve_deep(sub) with d.begin_transaction() as txn: diff --git a/tests/test_y_xml.py b/tests/test_y_xml.py index 46cf2ab..ce02984 100644 --- a/tests/test_y_xml.py +++ b/tests/test_y_xml.py @@ -100,7 +100,7 @@ def callback(e): attributes = e.keys delta = e.delta - subscription_id = x.observe(callback) + observation_id = x.observe(callback) # set initial attributes with d1.begin_transaction() as txn: @@ -162,7 +162,7 @@ def callback(e): delta = None # free the observer and make sure that callback is no longer called - x.unobserve(subscription_id) + x.unobserve(observation_id) with d1.begin_transaction() as txn: x.insert(txn, 1, "fgh") assert target == None @@ -188,7 +188,7 @@ def callback(e): attributes = e.keys nodes = e.delta - subscription_id = x.observe(callback) + observation_id = x.observe(callback) # insert initial attributes with d1.begin_transaction() as txn: @@ -256,7 +256,7 @@ def callback(e): nodes = None # free the observer and make sure that callback is no longer called - x.unobserve(subscription_id) + x.unobserve(observation_id) with d1.begin_transaction() as txn: x.insert_xml_element(txn, 0, "head") assert target == None diff --git a/y_py.pyi b/y_py.pyi index f629cf7..da2af6e 100644 --- a/y_py.pyi +++ b/y_py.pyi @@ -1,7 +1,7 @@ from typing import (Any, Callable, Dict, Iterable, Iterator, List, Literal, Optional, Tuple, TypedDict, Union) -class Origin: +class ObservationId: """ Tracks an observer callback. Pass this to the `unobserve`|`unobserve_deep` method to cancel its associated callback created by corresponding `observe`|`observe_deep` method call. @@ -108,7 +108,7 @@ class YDoc: """ def observe_after_transaction( self, callback: Callable[[AfterTransactionEvent]] - ) -> Origin: + ) -> ObservationId: """ Subscribe callback function to updates on the YDoc. The callback will receive encoded state updates and deletions when a document transaction is committed. @@ -117,7 +117,7 @@ class YDoc: callback: A function that receives YDoc state information affected by the transaction. Returns: - A subscription identifier that can be used to cancel the callback. + A observation identifier that can be used to cancel the callback. """ EncodedStateVector = bytes @@ -447,16 +447,16 @@ class YText: Deletes a specified range of of characters, starting at a given `index`. Both `index` and `length` are counted in terms of a number of UTF-8 character bytes. """ - def observe(self, f: Callable[[YTextEvent]]) -> Origin: + def observe(self, f: Callable[[YTextEvent]]) -> ObservationId: """ Assigns a callback function to listen to YText updates. Args: f: Callback function that runs when the text object receives an update. Returns: - A reference to the callback subscription. + A reference to the callback observation. """ - def observe_deep(self, f: Callable[[List[Event]]]) -> Origin: + def observe_deep(self, f: Callable[[List[Event]]]) -> ObservationId: """ Assigns a callback function to listen to the updates of the YText instance and those of its nested attributes. Currently, this listens to the same events as YText.observe, but in the future this will also listen to @@ -465,21 +465,21 @@ class YText: Args: f: Callback function that runs when the text object or its nested attributes receive an update. Returns: - A reference to the callback subscription. + A reference to the callback observation. """ - def unobserve(self, origin: Origin): + def unobserve(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ - def unobserve_deep(self, origin: Origin): + def unobserve_deep(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ class YTextEvent: @@ -628,37 +628,37 @@ class YArray: for item in array: print(item) """ - def observe(self, f: Callable[[YArrayEvent]]) -> Origin: + def observe(self, f: Callable[[YArrayEvent]]) -> ObservationId: """ Assigns a callback function to listen to YArray updates. Args: f: Callback function that runs when the array object receives an update. Returns: - An identifier associated with the callback subscription. + An identifier associated with the callback observation. """ - def observe_deep(self, f: Callable[[List[Event]]]) -> Origin: + def observe_deep(self, f: Callable[[List[Event]]]) -> ObservationId: """ Assigns a callback function to listen to the aggregated updates of the YArray and its child elements. Args: f: Callback function that runs when the array object or components receive an update. Returns: - An identifier associated with the callback subscription. + An identifier associated with the callback observation. """ - def unobserve(self, origin: Origin): + def unobserve(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ - def unobserve_deep(self, origin: Origin): + def unobserve_deep(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ YArrayObserver = Any @@ -812,37 +812,37 @@ class YMap: Returns: A view of all values in the YMap. The order of values is not stable. """ - def observe(self, f: Callable[[YMapEvent]]) -> Origin: + def observe(self, f: Callable[[YMapEvent]]) -> ObservationId: """ Assigns a callback function to listen to YMap updates. Args: f: Callback function that runs when the map object receives an update. Returns: - A reference to the callback subscription. Delete this observer in order to erase the associated callback function. + A reference to the callback observation. Delete this observer in order to erase the associated callback function. """ - def observe_deep(self, f: Callable[[List[Event]]]) -> Origin: + def observe_deep(self, f: Callable[[List[Event]]]) -> ObservationId: """ Assigns a callback function to listen to YMap and child element updates. Args: f: Callback function that runs when the map object or any of its tracked elements receive an update. Returns: - A reference to the callback subscription. Delete this observer in order to erase the associated callback function. + A reference to the callback observation. Delete this observer in order to erase the associated callback function. """ - def unobserve(self, origin: Origin): + def unobserve(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ - def unobserve_deep(self, origin: Origin): + def unobserve_deep(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ class YMapItemsView: @@ -1002,7 +1002,7 @@ class YXmlElement: Returns an iterator that enables a deep traversal of this XML node - starting from first child over this XML node successors using depth-first strategy. """ - def observe(self, f: Callable[[YXmlElementEvent]]) -> Origin: + def observe(self, f: Callable[[YXmlElementEvent]]) -> ObservationId: """ Subscribes to all operations happening over this instance of `YXmlElement`. All changes are batched and eventually triggered during transaction commit phase. @@ -1010,9 +1010,9 @@ class YXmlElement: Args: f: A callback function that receives update events. Returns: - A `Origin` that can be used to cancel the observer callback. + A `ObservationId` that can be used to cancel the observer callback. """ - def observe_deep(self, f: Callable[[List[Event]]]) -> Origin: + def observe_deep(self, f: Callable[[List[Event]]]) -> ObservationId: """ Subscribes to all operations happening over this instance of `YXmlElement` and its children. All changes are batched and eventually triggered during transaction commit phase. @@ -1020,21 +1020,21 @@ class YXmlElement: Args: f: A callback function that receives update events from the Xml element and its children. Returns: - A `Origin` that can be used to cancel the observer callback. + A `ObservationId` that can be used to cancel the observer callback. """ - def unobserve(self, origin: Origin): + def unobserve(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ - def unobserve_deep(self, origin: Origin): + def unobserve_deep(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ class YXmlFragment: @@ -1094,7 +1094,7 @@ class YXmlFragment: Returns an iterator that enables a deep traversal of this XML fragment - starting from first child over this XML fragment successors using depth-first strategy. """ - def observe(self, f: Callable[[YXmlElementEvent]]) -> Origin: + def observe(self, f: Callable[[YXmlElementEvent]]) -> ObservationId: """ Subscribes to all operations happening over this instance of `YXmlFragment`. All changes are batched and eventually triggered during transaction commit phase. @@ -1102,9 +1102,9 @@ class YXmlFragment: Args: f: A callback function that receives update events. Returns: - A `Origin` that can be used to cancel the observer callback. + A `ObservationId` that can be used to cancel the observer callback. """ - def observe_deep(self, f: Callable[[List[Event]]]) -> Origin: + def observe_deep(self, f: Callable[[List[Event]]]) -> ObservationId: """ Subscribes to all operations happening over this instance of `YXmlFragment` and its children. All changes are batched and eventually triggered during transaction commit phase. @@ -1112,21 +1112,21 @@ class YXmlFragment: Args: f: A callback function that receives update events from the Xml fragment and its children. Returns: - A `Origin` that can be used to cancel the observer callback. + A `ObservationId` that can be used to cancel the observer callback. """ - def unobserve(self, origin: Origin): + def unobserve(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ - def unobserve_deep(self, origin: Origin): + def unobserve_deep(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ class YXmlText: @@ -1182,7 +1182,7 @@ class YXmlText: An iterator that enables to traverse over all attributes of this XML node in unspecified order. """ - def observe(self, f: Callable[[YXmlTextEvent]]) -> Origin: + def observe(self, f: Callable[[YXmlTextEvent]]) -> ObservationId: """ Subscribes to all operations happening over this instance of `YXmlText`. All changes are batched and eventually triggered during transaction commit phase. @@ -1191,9 +1191,9 @@ class YXmlText: f: A callback function that receives update events. deep: Determines whether observer is triggered by changes to elements in the YXmlText. Returns: - A `Origin` that can be used to cancel the observer callback. + A `ObservationId` that can be used to cancel the observer callback. """ - def observe_deep(self, f: Callable[[List[Event]]]) -> Origin: + def observe_deep(self, f: Callable[[List[Event]]]) -> ObservationId: """ Subscribes to all operations happening over this instance of `YXmlText` and its children. All changes are batched and eventually triggered during transaction commit phase. @@ -1202,21 +1202,21 @@ class YXmlText: f: A callback function that receives update events of this element and its descendants. deep: Determines whether observer is triggered by changes to elements in the YXmlText. Returns: - A `Origin` that can be used to cancel the observer callback. + A `ObservationId` that can be used to cancel the observer callback. """ - def unobserve(self, origin: Origin): + def unobserve(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ - def unobserve_deep(self, origin: Origin): + def unobserve_deep(self, observation_id: ObservationId): """ - Cancels the observer callback associated with the `origin`. + Cancels the observer callback associated with the `observation_id`. Args: - origin: reference to a subscription provided by the `observe` method. + observation_id: reference to a observation provided by the `observe` method. """ class YXmlTextEvent: