insite-subscriptions-client 2.0.0 → 2.0.2
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/{src/index.ts → dist/index.d.ts} +2 -14
- 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 +2 -2
- package/src/Subscription.ts +0 -101
- package/src/SubscriptionArray.ts +0 -275
- package/src/SubscriptionGroup/SubscriptionGroup.ts +0 -319
- package/src/SubscriptionGroup/SubscriptionGroupItem.ts +0 -391
- package/src/SubscriptionGroup/common.ts +0 -13
- package/src/SubscriptionGroup/index.ts +0 -8
- package/src/SubscriptionGroup/types.ts +0 -121
- package/src/SubscriptionMap.ts +0 -455
- package/src/SubscriptionObject.ts +0 -168
- package/src/symbols.ts +0 -12
|
@@ -1,168 +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
|
-
const handleUpdateSymbol = Symbol("handleUpdate");
|
|
17
|
-
const updatesSymbol = Symbol("updates");
|
|
18
|
-
|
|
19
|
-
export type Updated = Record<string, unknown>;
|
|
20
|
-
export type Updates = null | Record<string, unknown>;
|
|
21
|
-
type UpdateHandler = (object: SubscriptionObject, updated: Updated, updates: Updates) => void;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export class SubscriptionObject {
|
|
25
|
-
constructor(updates?: Updates, onUpdate?: UpdateHandler) {
|
|
26
|
-
if (onUpdate)
|
|
27
|
-
this[handleUpdateSymbol] = onUpdate;
|
|
28
|
-
|
|
29
|
-
if (updates)
|
|
30
|
-
this[updateSymbol](updates);
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
[handleUpdateSymbol]?: UpdateHandler;
|
|
35
|
-
|
|
36
|
-
[updatesSymbol]: Updates = null;
|
|
37
|
-
|
|
38
|
-
[getHandleUpdateSymbol]() {
|
|
39
|
-
return this[handleUpdateSymbol];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
[setHandleUpdateSymbol](handleUpdate: UpdateHandler) {
|
|
43
|
-
return (this[handleUpdateSymbol] = handleUpdate);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
[updateSymbol](updates: Updates) {
|
|
47
|
-
if (updates) {
|
|
48
|
-
for (const key in this[updatesSymbol])// eslint-disable-line guard-for-in
|
|
49
|
-
delete this[key];
|
|
50
|
-
for (const key in updates)// eslint-disable-line guard-for-in
|
|
51
|
-
this[key] = updates[key];
|
|
52
|
-
this[updatesSymbol] = updates;
|
|
53
|
-
} else
|
|
54
|
-
this[clearSymbol]();
|
|
55
|
-
|
|
56
|
-
this[handleUpdateSymbol]?.(this, this, this[updatesSymbol]);
|
|
57
|
-
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
[getAsUpdatesSymbol]() {
|
|
62
|
-
return this[updatesSymbol] && { ...this[updatesSymbol] };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
[getAsInitialUpdatedSymbol]() {
|
|
66
|
-
return this.valueOf();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
[clearSymbol]() {
|
|
70
|
-
|
|
71
|
-
for (const key in this)// eslint-disable-line guard-for-in
|
|
72
|
-
delete this[key];
|
|
73
|
-
this[updatesSymbol] = null;
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
valueOf() {
|
|
78
|
-
return this[updatesSymbol] && this;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get [Symbol.toStringTag]() {
|
|
82
|
-
return "SubscriptionObject";
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
[key: string]: unknown;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
static updateSymbol = updateSymbol;
|
|
89
|
-
static getHandleUpdateSymbol = getHandleUpdateSymbol;
|
|
90
|
-
static setHandleUpdateSymbol = setHandleUpdateSymbol;
|
|
91
|
-
static getAsUpdatesSymbol = getAsUpdatesSymbol;
|
|
92
|
-
static getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;
|
|
93
|
-
static clearSymbol = clearSymbol;
|
|
94
|
-
static WithSubscription: typeof SubscriptionObjectWithSubscription;
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export class SubscriptionObjectWithSubscription extends SubscriptionObject {
|
|
100
|
-
constructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler, immediately = true) {
|
|
101
|
-
super(null, onUpdate);
|
|
102
|
-
|
|
103
|
-
this.publicationName = publicationName;
|
|
104
|
-
this.params = params;
|
|
105
|
-
|
|
106
|
-
if (immediately)
|
|
107
|
-
this[subscribeSymbol]();
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private publicationName;
|
|
112
|
-
private params;
|
|
113
|
-
private subscription: null | Subscription = null;
|
|
114
|
-
|
|
115
|
-
[subscribeSymbol]() {
|
|
116
|
-
|
|
117
|
-
if (!this.subscription)
|
|
118
|
-
this.subscription = new Subscription("object", this.publicationName, this.params, updates => this[updateSymbol](updates as Updates));
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
[unsubscribeSymbol]() {
|
|
123
|
-
|
|
124
|
-
if (this.subscription) {
|
|
125
|
-
this.subscription.cancel();
|
|
126
|
-
this.subscription = null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
[renewSymbol](publicationName?: string, params?: unknown[]) {
|
|
132
|
-
|
|
133
|
-
if (this.subscription) {
|
|
134
|
-
this[unsubscribeSymbol]();
|
|
135
|
-
|
|
136
|
-
if (publicationName)
|
|
137
|
-
if (Array.isArray(publicationName))
|
|
138
|
-
params = publicationName;
|
|
139
|
-
else
|
|
140
|
-
this.publicationName = publicationName;
|
|
141
|
-
|
|
142
|
-
if (params)
|
|
143
|
-
this.params = params;
|
|
144
|
-
|
|
145
|
-
this[subscribeSymbol]();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
[getSubscriptionSymbol]() {
|
|
151
|
-
return this.subscription;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
get [Symbol.toStringTag]() {
|
|
155
|
-
return "SubscriptionObjectWithSubscription";
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
static subscribeSymbol = subscribeSymbol;
|
|
160
|
-
static unsubscribeSymbol = unsubscribeSymbol;
|
|
161
|
-
static renewSymbol = renewSymbol;
|
|
162
|
-
static getSubscriptionSymbol = getSubscriptionSymbol;
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
SubscriptionObject.WithSubscription = SubscriptionObjectWithSubscription;
|
|
167
|
-
|
|
168
|
-
export { Updated as SubscriptionObjectUpdated };
|
package/src/symbols.ts
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");
|