insite-subscriptions-client 1.0.295 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Subscription.d.ts +18 -0
- package/dist/Subscription.d.ts.map +1 -0
- package/dist/SubscriptionArray.d.ts +73 -0
- package/dist/SubscriptionArray.d.ts.map +1 -0
- package/dist/SubscriptionGroup/SubscriptionGroup.d.ts +37 -0
- package/dist/SubscriptionGroup/SubscriptionGroup.d.ts.map +1 -0
- package/dist/SubscriptionGroup/SubscriptionGroupItem.d.ts +31 -0
- package/dist/SubscriptionGroup/SubscriptionGroupItem.d.ts.map +1 -0
- package/dist/SubscriptionGroup/common.d.ts +12 -0
- package/dist/SubscriptionGroup/common.d.ts.map +1 -0
- package/dist/SubscriptionGroup/index.d.ts +3 -0
- package/dist/SubscriptionGroup/index.d.ts.map +1 -0
- package/dist/SubscriptionGroup/types.d.ts +41 -0
- package/dist/SubscriptionGroup/types.d.ts.map +1 -0
- package/dist/SubscriptionMap.d.ts +102 -0
- package/dist/SubscriptionMap.d.ts.map +1 -0
- package/dist/SubscriptionObject.d.ts +47 -0
- package/dist/SubscriptionObject.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/symbols.d.ts +13 -0
- package/dist/symbols.d.ts.map +1 -0
- package/package.json +13 -12
- package/bun.lockb +0 -0
- package/lib/Subscription.js +0 -106
- package/lib/SubscriptionArray.js +0 -241
- package/lib/SubscriptionGroup/SubscriptionGroup.js +0 -292
- package/lib/SubscriptionGroup/SubscriptionGroupItem.js +0 -300
- package/lib/SubscriptionGroup/common.js +0 -1
- package/lib/SubscriptionGroup/index.js +0 -1
- package/lib/SubscriptionMap.js +0 -393
- package/lib/SubscriptionObject.js +0 -153
- package/lib/index.js +0 -21
- package/lib/symbols.js +0 -12
package/lib/SubscriptionMap.js
DELETED
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
import { removeOne } from "@nesvet/n";
|
|
2
|
-
import { Subscription } from "./Subscription";
|
|
3
|
-
import {
|
|
4
|
-
clearSymbol,
|
|
5
|
-
getAsInitialUpdatedSymbol,
|
|
6
|
-
getAsUpdatesSymbol,
|
|
7
|
-
getHandleUpdateSymbol,
|
|
8
|
-
getSubscriptionSymbol,
|
|
9
|
-
renewSymbol,
|
|
10
|
-
setHandleUpdateSymbol,
|
|
11
|
-
subscribeSymbol,
|
|
12
|
-
unsubscribeSymbol,
|
|
13
|
-
updateSymbol
|
|
14
|
-
} from "./symbols";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function makeSort(sort) {
|
|
18
|
-
|
|
19
|
-
const functionName = `function${performance.now().toString(36).replace(/\./g, "")}`;
|
|
20
|
-
|
|
21
|
-
const tempScript = document.createElement("script");
|
|
22
|
-
tempScript.textContent = `window.${functionName} = function sort(a, b) { return ${`${Object.entries(sort).map(([ key, value ]) => value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`).concat("0").join(" ")};`} }`;
|
|
23
|
-
document.head.append(tempScript);
|
|
24
|
-
tempScript.remove();
|
|
25
|
-
|
|
26
|
-
const sortFunction = window[functionName];
|
|
27
|
-
|
|
28
|
-
delete window[functionName];
|
|
29
|
-
|
|
30
|
-
return sortFunction;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export class SubscriptionMap extends Map {
|
|
35
|
-
constructor(updates, onUpdate) {
|
|
36
|
-
super();
|
|
37
|
-
|
|
38
|
-
if (onUpdate)
|
|
39
|
-
this.handleUpdate = onUpdate;
|
|
40
|
-
|
|
41
|
-
if (updates)
|
|
42
|
-
this.update(updates);
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
#updates = new Map();
|
|
47
|
-
|
|
48
|
-
sortList = null;
|
|
49
|
-
|
|
50
|
-
sortCompareFunction = null;
|
|
51
|
-
|
|
52
|
-
#fieldsToSort = [];
|
|
53
|
-
|
|
54
|
-
sorted = [];
|
|
55
|
-
|
|
56
|
-
sort() {
|
|
57
|
-
|
|
58
|
-
this.sorted.sort(this.sortCompareFunction);
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
[getHandleUpdateSymbol]() {
|
|
63
|
-
return this.handleUpdate;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
[setHandleUpdateSymbol](handleUpdate) {
|
|
67
|
-
return (this.handleUpdate = handleUpdate);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
#Item;
|
|
71
|
-
|
|
72
|
-
set Item(Item) {
|
|
73
|
-
this.#Item = Item;
|
|
74
|
-
|
|
75
|
-
if (this.size)
|
|
76
|
-
for (const [ _id, item ] of this)
|
|
77
|
-
this.set(_id, new Item(this, item));
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get Item() {
|
|
82
|
-
return this.#Item;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
update(updates) {
|
|
86
|
-
|
|
87
|
-
const updated = [];
|
|
88
|
-
updated.added = [];
|
|
89
|
-
updated.deleted = [];
|
|
90
|
-
|
|
91
|
-
if (updates) {
|
|
92
|
-
let shouldSort = false;
|
|
93
|
-
|
|
94
|
-
const Item = this.#Item;
|
|
95
|
-
const prevUpdates = this.#updates;
|
|
96
|
-
|
|
97
|
-
for (const update of updates)
|
|
98
|
-
switch (update?.[0]) {
|
|
99
|
-
case "i"/* initial */: {
|
|
100
|
-
const [ , array, sort ] = update;
|
|
101
|
-
|
|
102
|
-
if (sort) {
|
|
103
|
-
this.sortList = sort;
|
|
104
|
-
this.sortCompareFunction = makeSort(sort);
|
|
105
|
-
this.#fieldsToSort = [ ...new Set(Object.keys(sort).map(key => key.replace(/\..+/, ""))) ];
|
|
106
|
-
shouldSort = true;
|
|
107
|
-
} else {
|
|
108
|
-
this.sortList = null;
|
|
109
|
-
this.sortCompareFunction = null;
|
|
110
|
-
this.#fieldsToSort = [];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (this.size) {
|
|
114
|
-
const updatesMap = new Map();
|
|
115
|
-
for (const itemUpdates of array)
|
|
116
|
-
updatesMap.set(itemUpdates._id, itemUpdates);
|
|
117
|
-
|
|
118
|
-
for (const [ _id, item ] of this) {
|
|
119
|
-
const itemUpdates = updatesMap.get(_id);
|
|
120
|
-
if (itemUpdates) {
|
|
121
|
-
const prevItemUpdates = prevUpdates.get(_id);
|
|
122
|
-
|
|
123
|
-
if (Item)
|
|
124
|
-
item.update(itemUpdates);
|
|
125
|
-
else {
|
|
126
|
-
for (const key in prevItemUpdates)
|
|
127
|
-
delete item[key];
|
|
128
|
-
|
|
129
|
-
Object.assign(item, itemUpdates);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
prevUpdates.set(_id, itemUpdates);
|
|
133
|
-
updated.push(item);
|
|
134
|
-
updatesMap.delete(_id);
|
|
135
|
-
} else {
|
|
136
|
-
if (Item)
|
|
137
|
-
item.delete();
|
|
138
|
-
else
|
|
139
|
-
this.delete(_id);
|
|
140
|
-
prevUpdates.delete(_id);
|
|
141
|
-
updated.deleted.push(_id);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
for (const [ _id, itemUpdates ] of updatesMap) {
|
|
146
|
-
const item = Item ? new Item(this, itemUpdates) : { ...itemUpdates };
|
|
147
|
-
this.set(_id, item);
|
|
148
|
-
prevUpdates.set(_id, itemUpdates);
|
|
149
|
-
updated.push(item);
|
|
150
|
-
updated.added.push(item);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (this.sortList)
|
|
154
|
-
this.sorted = array.map(newItem => this.get(newItem._id));
|
|
155
|
-
|
|
156
|
-
} else
|
|
157
|
-
for (const itemUpdates of array) {
|
|
158
|
-
const item = Item ? new Item(this, itemUpdates) : { ...itemUpdates };
|
|
159
|
-
this.set(item._id, item);
|
|
160
|
-
this.sorted.push(item);
|
|
161
|
-
prevUpdates.set(item._id, itemUpdates);
|
|
162
|
-
updated.push(item);
|
|
163
|
-
updated.added.push(item);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
case "c"/* create */:
|
|
170
|
-
case "u"/* update */: {
|
|
171
|
-
let itemUpdates = update[1];
|
|
172
|
-
let item = this.get(itemUpdates._id);
|
|
173
|
-
|
|
174
|
-
if (item) {
|
|
175
|
-
const isAtomic = update[2] === true;
|
|
176
|
-
const updatedFields = isAtomic ? Object.keys(itemUpdates) : update[2];
|
|
177
|
-
const prevItemUpdates = prevUpdates.get(item._id);
|
|
178
|
-
|
|
179
|
-
if (Item)
|
|
180
|
-
item.update(itemUpdates);
|
|
181
|
-
else {
|
|
182
|
-
if (!isAtomic)
|
|
183
|
-
for (const key in prevItemUpdates)
|
|
184
|
-
delete item[key];
|
|
185
|
-
|
|
186
|
-
Object.assign(item, itemUpdates);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (isAtomic)
|
|
190
|
-
itemUpdates = Object.assign(prevItemUpdates, itemUpdates);
|
|
191
|
-
|
|
192
|
-
if (this.sortList && !shouldSort && (!updatedFields || updatedFields.some(fieldName => this.#fieldsToSort.includes(fieldName))))
|
|
193
|
-
shouldSort = true;
|
|
194
|
-
} else {
|
|
195
|
-
item = Item ? new Item(this, itemUpdates) : { ...itemUpdates };
|
|
196
|
-
this.set(item._id, item);
|
|
197
|
-
this.sorted.push(item);
|
|
198
|
-
if (this.sortList)
|
|
199
|
-
shouldSort = true;
|
|
200
|
-
updated.added.push(item);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
prevUpdates.set(item._id, itemUpdates);
|
|
204
|
-
updated.push(item);
|
|
205
|
-
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
case "d"/* delete */: {
|
|
210
|
-
const _id = update[1];
|
|
211
|
-
const itemToDelete = this.get(_id);
|
|
212
|
-
|
|
213
|
-
if (itemToDelete) {
|
|
214
|
-
if (Item)
|
|
215
|
-
itemToDelete.delete();
|
|
216
|
-
else
|
|
217
|
-
this.delete(_id);
|
|
218
|
-
prevUpdates.delete(_id);
|
|
219
|
-
removeOne(this.sorted, itemToDelete);
|
|
220
|
-
updated.deleted.push(_id);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
default:
|
|
227
|
-
this.clear();
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (shouldSort)
|
|
231
|
-
this.sort();
|
|
232
|
-
|
|
233
|
-
} else
|
|
234
|
-
this.clear();
|
|
235
|
-
|
|
236
|
-
this.handleUpdate?.(this, updated, updates?.[0] && updates);
|
|
237
|
-
|
|
238
|
-
return this;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
[updateSymbol] = this.update;
|
|
242
|
-
|
|
243
|
-
getAsUpdates() {
|
|
244
|
-
return (
|
|
245
|
-
(this.size || this.sortList) ?
|
|
246
|
-
[ [ "i"/* initial */, [ ...this.#updates.values() ], this.sortList ] ] :
|
|
247
|
-
null
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
[getAsUpdatesSymbol] = this.getAsUpdates;
|
|
252
|
-
|
|
253
|
-
getAsInitialUpdated() {
|
|
254
|
-
return Object.assign([ ...this.sorted ], {
|
|
255
|
-
added: [ ...this.sorted ],
|
|
256
|
-
deleted: []
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;
|
|
261
|
-
|
|
262
|
-
clear() {
|
|
263
|
-
|
|
264
|
-
super.clear();
|
|
265
|
-
this.#updates.clear();
|
|
266
|
-
this.sorted = [];
|
|
267
|
-
this.sortList = null;
|
|
268
|
-
this.sortCompareFunction = null;
|
|
269
|
-
this.#fieldsToSort = [];
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
[clearSymbol] = this.clear;
|
|
274
|
-
|
|
275
|
-
valueOf() {
|
|
276
|
-
return this.sorted;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
get [Symbol.toStringTag]() {
|
|
280
|
-
return "SubscriptionMap";
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
static updateSymbol = updateSymbol;
|
|
285
|
-
static getHandleUpdateSymbol = getHandleUpdateSymbol;
|
|
286
|
-
static setHandleUpdateSymbol = setHandleUpdateSymbol;
|
|
287
|
-
static getAsUpdatesSymbol = getAsUpdatesSymbol;
|
|
288
|
-
static getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;
|
|
289
|
-
static clearSymbol = clearSymbol;
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
SubscriptionMap.WithSubscription = class SubscriptionMapWithSubscription extends SubscriptionMap {
|
|
295
|
-
constructor(publicationName, params, onUpdate, immediately = true) {
|
|
296
|
-
super(null, onUpdate);
|
|
297
|
-
|
|
298
|
-
this.publicationName = publicationName;
|
|
299
|
-
this.params = params;
|
|
300
|
-
|
|
301
|
-
if (immediately)
|
|
302
|
-
this.subscribe();
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
subscription = null;
|
|
307
|
-
|
|
308
|
-
subscribe() {
|
|
309
|
-
|
|
310
|
-
if (!this.subscription)
|
|
311
|
-
this.subscription = new Subscription("map", this.publicationName, this.params, updates => this.update(updates));
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
get [subscribeSymbol]() {
|
|
316
|
-
return this.subscribe;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
unsubscribe() {
|
|
320
|
-
|
|
321
|
-
if (this.subscription) {
|
|
322
|
-
this.subscription.cancel();
|
|
323
|
-
this.subscription = null;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
get [unsubscribeSymbol]() {
|
|
329
|
-
return this.unsubscribe;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
renew(publicationName, params) {
|
|
333
|
-
|
|
334
|
-
if (this.subscription) {
|
|
335
|
-
this.unsubscribe();
|
|
336
|
-
|
|
337
|
-
if (publicationName)
|
|
338
|
-
if (Array.isArray(publicationName))
|
|
339
|
-
params = publicationName;
|
|
340
|
-
else
|
|
341
|
-
this.publicationName = publicationName;
|
|
342
|
-
|
|
343
|
-
if (params)
|
|
344
|
-
this.params = params;
|
|
345
|
-
|
|
346
|
-
this.subscribe();
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
get [renewSymbol]() {
|
|
352
|
-
return this.renew;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
[getSubscriptionSymbol]() {
|
|
356
|
-
return this.subscription;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
get [Symbol.toStringTag]() {
|
|
360
|
-
return "SubscriptionMapWithSubscription";
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
static subscribeSymbol = subscribeSymbol;
|
|
365
|
-
static unsubscribeSymbol = unsubscribeSymbol;
|
|
366
|
-
static renewSymbol = renewSymbol;
|
|
367
|
-
static getSubscriptionSymbol = getSubscriptionSymbol;
|
|
368
|
-
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
SubscriptionMap.Item = class SubscriptionMapItem {
|
|
373
|
-
constructor(map, updates) {
|
|
374
|
-
this.#map = map;
|
|
375
|
-
|
|
376
|
-
this.update(updates);
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
#map;
|
|
381
|
-
|
|
382
|
-
update(updates) {
|
|
383
|
-
Object.assign(this, updates);
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
delete() {
|
|
388
|
-
|
|
389
|
-
this.#map.delete(this._id);
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { Subscription } from "./Subscription";
|
|
2
|
-
import {
|
|
3
|
-
clearSymbol,
|
|
4
|
-
getAsInitialUpdatedSymbol,
|
|
5
|
-
getAsUpdatesSymbol,
|
|
6
|
-
getHandleUpdateSymbol,
|
|
7
|
-
getSubscriptionSymbol,
|
|
8
|
-
renewSymbol,
|
|
9
|
-
setHandleUpdateSymbol,
|
|
10
|
-
subscribeSymbol,
|
|
11
|
-
unsubscribeSymbol,
|
|
12
|
-
updateSymbol
|
|
13
|
-
} from "./symbols";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export class SubscriptionObject {
|
|
17
|
-
#handleUpdate;
|
|
18
|
-
|
|
19
|
-
constructor(updates, onUpdate) {
|
|
20
|
-
this.#handleUpdate = onUpdate;
|
|
21
|
-
|
|
22
|
-
if (updates)
|
|
23
|
-
this[updateSymbol](updates);
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
#updates = null;
|
|
28
|
-
|
|
29
|
-
[getHandleUpdateSymbol]() {
|
|
30
|
-
return this.#handleUpdate;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
[setHandleUpdateSymbol](handleUpdate) {
|
|
34
|
-
return (this.#handleUpdate = handleUpdate);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[updateSymbol](updates) {
|
|
38
|
-
if (updates) {
|
|
39
|
-
for (const key in this.#updates)
|
|
40
|
-
delete this[key];
|
|
41
|
-
for (const key in updates)
|
|
42
|
-
this[key] = updates[key];
|
|
43
|
-
this.#updates = updates;
|
|
44
|
-
} else
|
|
45
|
-
this[clearSymbol]();
|
|
46
|
-
|
|
47
|
-
this.#handleUpdate?.(this, this, this.#updates);
|
|
48
|
-
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
[getAsUpdatesSymbol]() {
|
|
53
|
-
return this.#updates && { ...this.#updates };
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
[getAsInitialUpdatedSymbol]() {
|
|
57
|
-
return this.valueOf();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[clearSymbol]() {
|
|
61
|
-
|
|
62
|
-
for (const key in this)
|
|
63
|
-
delete this[key];
|
|
64
|
-
this.#updates = null;
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
valueOf() {
|
|
69
|
-
return this.#updates && this;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get [Symbol.toStringTag]() {
|
|
73
|
-
return "SubscriptionObject";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
static updateSymbol = updateSymbol;
|
|
78
|
-
static getHandleUpdateSymbol = getHandleUpdateSymbol;
|
|
79
|
-
static setHandleUpdateSymbol = setHandleUpdateSymbol;
|
|
80
|
-
static getAsUpdatesSymbol = getAsUpdatesSymbol;
|
|
81
|
-
static getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;
|
|
82
|
-
static clearSymbol = clearSymbol;
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
SubscriptionObject.WithSubscription = class SubscriptionObjectWithSubscription extends SubscriptionObject {
|
|
88
|
-
#publicationName;
|
|
89
|
-
#params;
|
|
90
|
-
|
|
91
|
-
constructor(publicationName, params, onUpdate, immediately = true) {
|
|
92
|
-
super(null, onUpdate);
|
|
93
|
-
|
|
94
|
-
this.#publicationName = publicationName;
|
|
95
|
-
this.#params = params;
|
|
96
|
-
|
|
97
|
-
if (immediately)
|
|
98
|
-
this[subscribeSymbol]();
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
#subscription = null;
|
|
103
|
-
|
|
104
|
-
[subscribeSymbol]() {
|
|
105
|
-
|
|
106
|
-
if (!this.#subscription)
|
|
107
|
-
this.#subscription = new Subscription("object", this.#publicationName, this.#params, updates => this[updateSymbol](updates));
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
[unsubscribeSymbol]() {
|
|
112
|
-
|
|
113
|
-
if (this.#subscription) {
|
|
114
|
-
this.#subscription.cancel();
|
|
115
|
-
this.#subscription = null;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
[renewSymbol](publicationName, params) {
|
|
121
|
-
|
|
122
|
-
if (this.#subscription) {
|
|
123
|
-
this[unsubscribeSymbol]();
|
|
124
|
-
|
|
125
|
-
if (publicationName)
|
|
126
|
-
if (Array.isArray(publicationName))
|
|
127
|
-
params = publicationName;
|
|
128
|
-
else
|
|
129
|
-
this.#publicationName = publicationName;
|
|
130
|
-
|
|
131
|
-
if (params)
|
|
132
|
-
this.#params = params;
|
|
133
|
-
|
|
134
|
-
this[subscribeSymbol]();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
[getSubscriptionSymbol]() {
|
|
140
|
-
return this.#subscription;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
get [Symbol.toStringTag]() {
|
|
144
|
-
return "SubscriptionObjectWithSubscription";
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
static subscribeSymbol = subscribeSymbol;
|
|
149
|
-
static unsubscribeSymbol = unsubscribeSymbol;
|
|
150
|
-
static renewSymbol = renewSymbol;
|
|
151
|
-
static getSubscriptionSymbol = getSubscriptionSymbol;
|
|
152
|
-
|
|
153
|
-
};
|
package/lib/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#if _SSR
|
|
2
|
-
// export { default as Subscription, initialsMap, subscriptionContext } from "./Subscription.js";
|
|
3
|
-
//#else
|
|
4
|
-
export * from "./Subscription.js";
|
|
5
|
-
export * from "./SubscriptionArray";
|
|
6
|
-
export * from "./SubscriptionGroup";
|
|
7
|
-
export * from "./SubscriptionMap";
|
|
8
|
-
export * from "./SubscriptionObject";
|
|
9
|
-
export { clearSymbol,
|
|
10
|
-
getAsInitialUpdatedSymbol,
|
|
11
|
-
getAsUpdatesSymbol,
|
|
12
|
-
getHandleSubscriptionSymbol,
|
|
13
|
-
getHandleUpdateSymbol,
|
|
14
|
-
getSubscriptionSymbol,
|
|
15
|
-
renewSymbol,
|
|
16
|
-
setHandleSubscriptionSymbol,
|
|
17
|
-
setHandleUpdateSymbol,
|
|
18
|
-
subscribeSymbol,
|
|
19
|
-
unsubscribeSymbol,
|
|
20
|
-
updateSymbol } from "./symbols";
|
|
21
|
-
//#endif
|
package/lib/symbols.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const updateSymbol = Symbol("update");
|
|
2
|
-
export const getHandleUpdateSymbol = Symbol("getHandleUpdate");
|
|
3
|
-
export const setHandleUpdateSymbol = Symbol("setHandleUpdate");
|
|
4
|
-
export const getAsUpdatesSymbol = Symbol("getAsUpdates");
|
|
5
|
-
export const getAsInitialUpdatedSymbol = Symbol("getAsInitialUpdated");
|
|
6
|
-
export const clearSymbol = Symbol("clear");
|
|
7
|
-
export const subscribeSymbol = Symbol("subscribe");
|
|
8
|
-
export const unsubscribeSymbol = Symbol("unsubscribe");
|
|
9
|
-
export const renewSymbol = Symbol("renew");
|
|
10
|
-
export const getSubscriptionSymbol = Symbol("getSubscription");
|
|
11
|
-
export const getHandleSubscriptionSymbol = Symbol("getHandleSubscription");
|
|
12
|
-
export const setHandleSubscriptionSymbol = Symbol("setHandleSubscription");
|