@@ -46,7 +46,7 @@ extension LoroDoc{
46
46
* - `doc.import(data)` is called.
47
47
* - `doc.checkout(version)` is called.
48
48
*/
49
- public func subscribe( containerId: ContainerId , callback: @escaping ( DiffEvent ) -> Void ) -> Subscription {
49
+ public func subscribe( containerId: ContainerId , callback: @escaping ( DiffEvent ) -> Void ) -> Subscription {
50
50
let closureSubscriber = ClosureSubscriber ( closure: callback)
51
51
return self . subscribe ( containerId: containerId, subscriber: closureSubscriber)
52
52
}
@@ -59,3 +59,111 @@ extension LoroDoc{
59
59
return self . subscribeLocalUpdate ( callback: closureLocalUpdate)
60
60
}
61
61
}
62
+
63
+ extension LoroText {
64
+ /** Subscribe the events of a container.
65
+ *
66
+ * The callback will be invoked when the container is changed.
67
+ * Returns a subscription id that can be used to unsubscribe.
68
+ *
69
+ * The events will be emitted after a transaction is committed. A transaction is committed when:
70
+ * - `doc.commit()` is called.
71
+ * - `doc.exportFrom(version)` is called.
72
+ * - `doc.import(data)` is called.
73
+ * - `doc.checkout(version)` is called.
74
+ */
75
+ public func subscribe( callback: @escaping ( DiffEvent ) -> Void ) -> Subscription ? {
76
+ let closureSubscriber = ClosureSubscriber ( closure: callback)
77
+ return self . subscribe ( subscriber: closureSubscriber)
78
+ }
79
+ }
80
+
81
+ extension LoroList {
82
+ /** Subscribe the events of a container.
83
+ *
84
+ * The callback will be invoked when the container is changed.
85
+ * Returns a subscription id that can be used to unsubscribe.
86
+ *
87
+ * The events will be emitted after a transaction is committed. A transaction is committed when:
88
+ * - `doc.commit()` is called.
89
+ * - `doc.exportFrom(version)` is called.
90
+ * - `doc.import(data)` is called.
91
+ * - `doc.checkout(version)` is called.
92
+ */
93
+ public func subscribe( callback: @escaping ( DiffEvent ) -> Void ) -> Subscription ? {
94
+ let closureSubscriber = ClosureSubscriber ( closure: callback)
95
+ return self . subscribe ( subscriber: closureSubscriber)
96
+ }
97
+ }
98
+
99
+ extension LoroMap {
100
+ /** Subscribe the events of a container.
101
+ *
102
+ * The callback will be invoked when the container is changed.
103
+ * Returns a subscription id that can be used to unsubscribe.
104
+ *
105
+ * The events will be emitted after a transaction is committed. A transaction is committed when:
106
+ * - `doc.commit()` is called.
107
+ * - `doc.exportFrom(version)` is called.
108
+ * - `doc.import(data)` is called.
109
+ * - `doc.checkout(version)` is called.
110
+ */
111
+ public func subscribe( callback: @escaping ( DiffEvent ) -> Void ) -> Subscription ? {
112
+ let closureSubscriber = ClosureSubscriber ( closure: callback)
113
+ return self . subscribe ( subscriber: closureSubscriber)
114
+ }
115
+ }
116
+
117
+ extension LoroTree {
118
+ /** Subscribe the events of a container.
119
+ *
120
+ * The callback will be invoked when the container is changed.
121
+ * Returns a subscription id that can be used to unsubscribe.
122
+ *
123
+ * The events will be emitted after a transaction is committed. A transaction is committed when:
124
+ * - `doc.commit()` is called.
125
+ * - `doc.exportFrom(version)` is called.
126
+ * - `doc.import(data)` is called.
127
+ * - `doc.checkout(version)` is called.
128
+ */
129
+ public func subscribe( callback: @escaping ( DiffEvent ) -> Void ) -> Subscription ? {
130
+ let closureSubscriber = ClosureSubscriber ( closure: callback)
131
+ return self . subscribe ( subscriber: closureSubscriber)
132
+ }
133
+ }
134
+
135
+ extension LoroMovableList {
136
+ /** Subscribe the events of a container.
137
+ *
138
+ * The callback will be invoked when the container is changed.
139
+ * Returns a subscription id that can be used to unsubscribe.
140
+ *
141
+ * The events will be emitted after a transaction is committed. A transaction is committed when:
142
+ * - `doc.commit()` is called.
143
+ * - `doc.exportFrom(version)` is called.
144
+ * - `doc.import(data)` is called.
145
+ * - `doc.checkout(version)` is called.
146
+ */
147
+ public func subscribe( callback: @escaping ( DiffEvent ) -> Void ) -> Subscription ? {
148
+ let closureSubscriber = ClosureSubscriber ( closure: callback)
149
+ return self . subscribe ( subscriber: closureSubscriber)
150
+ }
151
+ }
152
+
153
+ extension LoroCounter {
154
+ /** Subscribe the events of a container.
155
+ *
156
+ * The callback will be invoked when the container is changed.
157
+ * Returns a subscription id that can be used to unsubscribe.
158
+ *
159
+ * The events will be emitted after a transaction is committed. A transaction is committed when:
160
+ * - `doc.commit()` is called.
161
+ * - `doc.exportFrom(version)` is called.
162
+ * - `doc.import(data)` is called.
163
+ * - `doc.checkout(version)` is called.
164
+ */
165
+ public func subscribe( callback: @escaping ( DiffEvent ) -> Void ) -> Subscription ? {
166
+ let closureSubscriber = ClosureSubscriber ( closure: callback)
167
+ return self . subscribe ( subscriber: closureSubscriber)
168
+ }
169
+ }
0 commit comments