@@ -45,6 +45,12 @@ class Doc:
45
45
"""Subscribes a callback to be called with the shared document subdoc change event.
46
46
Returns a subscription ID that can be used to unsubscribe."""
47
47
48
+ class Subscription :
49
+ """Observer subscription"""
50
+
51
+ def drop (self ) -> None :
52
+ """Drop the subscription, effectively unobserving."""
53
+
48
54
class Transaction :
49
55
"""Document transaction"""
50
56
@@ -94,13 +100,13 @@ class Text:
94
100
def get_string (self , txn : Transaction ) -> str :
95
101
"""Returns a text representation of the current shared text."""
96
102
97
- def observe (self , callback : Callable [[TextEvent ], None ]) -> int :
103
+ def observe (self , callback : Callable [[TextEvent ], None ]) -> Subscription :
98
104
"""Subscribes a callback to be called with the shared text change event.
99
- Returns a subscription ID that can be used to unsubscribe."""
105
+ Returns a subscription that can be used to unsubscribe."""
100
106
101
- def unobserve (self , subscription_id : int ) -> None :
107
+ def unobserve (self , subscription : Subscription ) -> None :
102
108
"""Unsubscribes previously subscribed event callback identified by given
103
- `subscription_id `."""
109
+ `subscription `."""
104
110
105
111
class Array :
106
112
"""Shared array."""
@@ -123,18 +129,18 @@ class Array:
123
129
def to_json (self , txn : Transaction ) -> str :
124
130
"""Returns a JSON representation of the current array."""
125
131
126
- def observe (self , callback : Callable [[TextEvent ], None ]) -> int :
132
+ def observe (self , callback : Callable [[TextEvent ], None ]) -> Subscription :
127
133
"""Subscribes a callback to be called with the array change event.
128
- Returns a subscription ID that can be used to unsubscribe."""
134
+ Returns a subscription that can be used to unsubscribe."""
129
135
130
- def observe_deep (self , callback : Callable [[TextEvent ], None ]) -> int :
136
+ def observe_deep (self , callback : Callable [[TextEvent ], None ]) -> Subscription :
131
137
"""Subscribes a callback to be called with the array change event
132
138
and its nested elements.
133
- Returns a subscription ID that can be used to unsubscribe."""
139
+ Returns a subscription that can be used to unsubscribe."""
134
140
135
- def unobserve (self , subscription_id : int ) -> None :
141
+ def unobserve (self , subscription : Subscription ) -> None :
136
142
"""Unsubscribes previously subscribed event callback identified by given
137
- `subscription_id `."""
143
+ `subscription `."""
138
144
139
145
class Map :
140
146
"""Shared map."""
@@ -154,15 +160,15 @@ class Map:
154
160
def to_json (self , txn : Transaction ) -> str :
155
161
"""Returns a JSON representation of the current map."""
156
162
157
- def observe (self , callback : Callable [[TextEvent ], None ]) -> int :
163
+ def observe (self , callback : Callable [[TextEvent ], None ]) -> Subscription :
158
164
"""Subscribes a callback to be called with the map change event.
159
- Returns a subscription ID that can be used to unsubscribe."""
165
+ Returns a subscription that can be used to unsubscribe."""
160
166
161
- def observe_deep (self , callback : Callable [[TextEvent ], None ]) -> int :
167
+ def observe_deep (self , callback : Callable [[TextEvent ], None ]) -> Subscription :
162
168
"""Subscribes a callback to be called with the map change event
163
169
and its nested elements.
164
- Returns a subscription ID that can be used to unsubscribe."""
170
+ Returns a subscription that can be used to unsubscribe."""
165
171
166
- def unobserve (self , subscription_id : int ) -> None :
172
+ def unobserve (self , subscription : Subscription ) -> None :
167
173
"""Unsubscribes previously subscribed event callback identified by given
168
- `subscription_id `."""
174
+ `subscription `."""
0 commit comments