@expressive/mvc 1.0.0-beta.8 → 1.0.0
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/lib/index.d.ts +594 -0
- package/lib/index.esm.js +1606 -0
- package/lib/index.js +1498 -880
- package/package.json +20 -22
- package/types/context.d.ts +0 -59
- package/types/dispatch.d.ts +0 -55
- package/types/index.d.ts +0 -9
- package/types/instructions.d.ts +0 -101
- package/types/lifecycle.d.ts +0 -30
- package/types/model.d.ts +0 -421
- package/types/selector.ts +0 -29
- package/types/types.d.ts +0 -14
package/types/model.d.ts
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import Dispatch from './dispatch';
|
|
2
|
-
import Lifecycle from './lifecycle';
|
|
3
|
-
import { Selector } from './selector';
|
|
4
|
-
import { Class, InstanceOf, Key } from './types';
|
|
5
|
-
|
|
6
|
-
interface PropertyDescriptor<T> {
|
|
7
|
-
configurable?: boolean;
|
|
8
|
-
enumerable?: boolean;
|
|
9
|
-
value?: T;
|
|
10
|
-
writable?: boolean;
|
|
11
|
-
get?(): T;
|
|
12
|
-
set?(v: T): void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export namespace Model {
|
|
16
|
-
/** Exotic value, actual value is contained. */
|
|
17
|
-
interface Ref<T = any> {
|
|
18
|
-
(next: T): void;
|
|
19
|
-
current: T | null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type GetFunction<T> = (within?: Subscriber) => T;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Property initializer, will run upon instance creation.
|
|
26
|
-
* Optional returned callback will run when once upon first access.
|
|
27
|
-
*/
|
|
28
|
-
type Instruction<T> = (this: Controller, key: string) =>
|
|
29
|
-
void | GetFunction<T> | PropertyDescriptor<T>;
|
|
30
|
-
|
|
31
|
-
/** Shallow replacement given all entries of Model */
|
|
32
|
-
type Overlay<T, R> = { [K in keyof Entries<T>]: R };
|
|
33
|
-
|
|
34
|
-
/** Subset of `keyof T` excluding keys defined by base Model */
|
|
35
|
-
type Fields<T, E = Model> = Exclude<keyof T, keyof E>;
|
|
36
|
-
|
|
37
|
-
/** Object containing data found in T. */
|
|
38
|
-
type Entries<T, E = Model> = Pick<T, Fields<T, E>>;
|
|
39
|
-
|
|
40
|
-
/** Actual value stored in state. */
|
|
41
|
-
type Value<R> = R extends Ref<infer T> ? T : R;
|
|
42
|
-
|
|
43
|
-
/** Values from current state of given controller. */
|
|
44
|
-
type State<T, K extends keyof T = Fields<T, Model>> = {
|
|
45
|
-
[P in K]: Value<T[P]>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** Object comperable to data which may be found in T. */
|
|
49
|
-
type Data<T, E = Model> = Partial<Entries<T, E>>;
|
|
50
|
-
|
|
51
|
-
/** Subset of `keyof T` excluding keys defined by base Model, except lifecycle. */
|
|
52
|
-
type Events<T> = Omit<T, Exclude<keyof Model, keyof Lifecycle>>;
|
|
53
|
-
|
|
54
|
-
type EventsCompat<T> = keyof T | keyof Lifecycle;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Field selector which includes Model-Lifecycle events.
|
|
58
|
-
* Can select for any tracked-property on a specified controller.
|
|
59
|
-
*
|
|
60
|
-
* Function `SelectEvent<T>` is a preferred alterative to string `keyof T`.
|
|
61
|
-
*
|
|
62
|
-
* ---
|
|
63
|
-
*
|
|
64
|
-
* ```js
|
|
65
|
-
* Model.on(x => x.foo.bar.didMountComponent, cb)
|
|
66
|
-
* ```
|
|
67
|
-
* is equivalent to, while also more robust than:
|
|
68
|
-
* ```js
|
|
69
|
-
* Model.on(["foo", "bar", "didMountComponent"], cb)
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
type SelectEvents<T> = Selector.Function<Events<T>>;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Field selector function you provide. Argument is a representation of controller specified.
|
|
76
|
-
* *When used as an argument*, return a chain of properties desired for a given operation.
|
|
77
|
-
*
|
|
78
|
-
* Allows for refactor safe selection of properties belonging to a controller.
|
|
79
|
-
* Using selectors is generally recommended to prevent unexpected behavior to be caused by bundling of your code.
|
|
80
|
-
*
|
|
81
|
-
* ---
|
|
82
|
-
*
|
|
83
|
-
* **Selector used to update specific properties:**
|
|
84
|
-
*
|
|
85
|
-
* ```js
|
|
86
|
-
* Model.update(x => x.foo.bar.baz)
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
|
-
* is equivalent to, while more robust than:
|
|
90
|
-
*
|
|
91
|
-
* ```js
|
|
92
|
-
* Model.update(["foo", "bar", "baz"])
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
type SelectFields<T> = Selector.Function<Omit<T, keyof Model>>;
|
|
96
|
-
|
|
97
|
-
type SelectField<T> = (arg: Omit<T, keyof Model>) => any;
|
|
98
|
-
|
|
99
|
-
export class Controller {
|
|
100
|
-
state: BunchOf<any>;
|
|
101
|
-
subject: {};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Place a given key's property under management.
|
|
105
|
-
*
|
|
106
|
-
* Note: If property is occupied by an instruction, it will be run.
|
|
107
|
-
*/
|
|
108
|
-
add(key: string): void;
|
|
109
|
-
|
|
110
|
-
/** Add property to managed state. */
|
|
111
|
-
manage(key: string, initial: any, effect?: EffectCallback<any, any>): void;
|
|
112
|
-
|
|
113
|
-
select(using?: Query): string[];
|
|
114
|
-
|
|
115
|
-
sets(key: string, effect?: EffectCallback<any, any>): (value: any) => void;
|
|
116
|
-
|
|
117
|
-
watch(target: string | Iterable<string> | Query, handler: Function, squash?: boolean, once?: boolean): Callback;
|
|
118
|
-
|
|
119
|
-
addListener(batch: BunchOf<RequestCallback>): Callback;
|
|
120
|
-
|
|
121
|
-
update(key: string, value?: any): void;
|
|
122
|
-
|
|
123
|
-
include(cb: RequestCallback): void;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
type Listener = {
|
|
127
|
-
commit(): void;
|
|
128
|
-
release(): void;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export class Subscriber {
|
|
132
|
-
proxy: any;
|
|
133
|
-
active: boolean;
|
|
134
|
-
follows: BunchOf<Callback>;
|
|
135
|
-
dependant: Set<Listener>;
|
|
136
|
-
parent: Controller;
|
|
137
|
-
|
|
138
|
-
follow(key: string, cb?: Callback | undefined): void;
|
|
139
|
-
commit(): Callback;
|
|
140
|
-
release(): Callback;
|
|
141
|
-
onUpdate(): void;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
declare const CONTROL: unique symbol;
|
|
146
|
-
declare const LOCAL: unique symbol;
|
|
147
|
-
declare const STATE: unique symbol;
|
|
148
|
-
|
|
149
|
-
export interface Model extends Dispatch, Lifecycle {}
|
|
150
|
-
|
|
151
|
-
export abstract class Model {
|
|
152
|
-
/**
|
|
153
|
-
* Circular reference to `this` controller.
|
|
154
|
-
*
|
|
155
|
-
* Useful to obtain full reference where one has already destructured.
|
|
156
|
-
*
|
|
157
|
-
* ---
|
|
158
|
-
*
|
|
159
|
-
* **Retrieve root object after destructure:**
|
|
160
|
-
*
|
|
161
|
-
* ```js
|
|
162
|
-
* const { active, get: instance } = MyModel.use();
|
|
163
|
-
* ```
|
|
164
|
-
* Is equivalent to:
|
|
165
|
-
* ```js
|
|
166
|
-
* const instance = MyModel.use();
|
|
167
|
-
* const { active } = instance;
|
|
168
|
-
* ```
|
|
169
|
-
* ---
|
|
170
|
-
*
|
|
171
|
-
* **Access values without watch:**
|
|
172
|
-
*
|
|
173
|
-
* Also useful to "peek" values without indicating you
|
|
174
|
-
* want them watched, via built-in hook.
|
|
175
|
-
*
|
|
176
|
-
* ```js
|
|
177
|
-
* const { firstName, get } = Hello.use();
|
|
178
|
-
*
|
|
179
|
-
* return (
|
|
180
|
-
* <div onClick={() => {
|
|
181
|
-
* alert(`Hello ${firstName} ${get.lastName}`)
|
|
182
|
-
* }}>
|
|
183
|
-
* Hello {firstName}
|
|
184
|
-
* </div>
|
|
185
|
-
* )
|
|
186
|
-
* ```
|
|
187
|
-
* Here, it would be a waste to trigger an update every time lastName changes (say, due to an input).
|
|
188
|
-
* Using `get.lastName` allows us to obtain the value only when needed.
|
|
189
|
-
*/
|
|
190
|
-
get: this;
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Circular reference to `this` controller.
|
|
194
|
-
*
|
|
195
|
-
* Useful mnemonic to update values on a controller from within a component.
|
|
196
|
-
*
|
|
197
|
-
* ---
|
|
198
|
-
*
|
|
199
|
-
* ```js
|
|
200
|
-
* const { active, set } = MyToggle.use();
|
|
201
|
-
*
|
|
202
|
-
* return (
|
|
203
|
-
* <div onClick={() => set.active = !active}>
|
|
204
|
-
* Toggle is {active ? "active" : "inactive"}!
|
|
205
|
-
* </div>
|
|
206
|
-
* )
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
|
-
set: this;
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Mark this instance for garbage-collection and send `willDestroy` event to all listeners.
|
|
213
|
-
*
|
|
214
|
-
* Implemented by class in-use, see `Model.willDestroy`.
|
|
215
|
-
*/
|
|
216
|
-
destroy(): void;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Callback for when a controller is fully activated and about to be in use.
|
|
220
|
-
*
|
|
221
|
-
* Invoke after initial state has been locked, and instance is now aware of what values should be tracked.
|
|
222
|
-
*/
|
|
223
|
-
didCreate?(): void;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Callback for when a controller is about to expire.
|
|
227
|
-
*/
|
|
228
|
-
willDestroy?(): void;
|
|
229
|
-
|
|
230
|
-
/** Attaches this controller to a component. */
|
|
231
|
-
tap(): this;
|
|
232
|
-
|
|
233
|
-
/** Tracks specific key of this controller within a component. */
|
|
234
|
-
tap <K extends Model.Fields<this>> (key: K, expect?: boolean): this[K];
|
|
235
|
-
tap <K extends Model.Fields<this>> (key: K, expect: true): Exclude<this[K], undefined>;
|
|
236
|
-
|
|
237
|
-
tap <K extends Model.SelectField<this>> (key: K, expect?: boolean): ReturnType<K>;
|
|
238
|
-
tap <K extends Model.SelectField<this>> (key: K, expect: true): Exclude<ReturnType<K>, undefined>;
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* **React Hook** - Attach to instance of this controller within ambient component.
|
|
242
|
-
*
|
|
243
|
-
* This method will fire lifecycle events on given controller.
|
|
244
|
-
*
|
|
245
|
-
* @param id - Argument passed to controller-lifecycle methods. Use to identify the consumer.
|
|
246
|
-
*/
|
|
247
|
-
tag(id?: Key): this;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* **React Hook** - Attach to instance of this controller within ambient component.
|
|
251
|
-
*
|
|
252
|
-
* This method will fire lifecycle events on given controller.
|
|
253
|
-
*
|
|
254
|
-
* @param idFactory - Will be invoked with fetched instance. Use this to register a tag as-needed.
|
|
255
|
-
*/
|
|
256
|
-
tag(idFactory: (idFactory: this) => Key | void): this;
|
|
257
|
-
|
|
258
|
-
/** Controller for this instance. */
|
|
259
|
-
[CONTROL]: Model.Controller;
|
|
260
|
-
|
|
261
|
-
/** Current state of this instance. */
|
|
262
|
-
[STATE]?: Model.State<this>;
|
|
263
|
-
|
|
264
|
-
/** Current subscriber (if present) while used in a live context (e.g. hook or effect). */
|
|
265
|
-
[LOCAL]?: Model.Subscriber;
|
|
266
|
-
|
|
267
|
-
/** Use symbol to access controller of a model. */
|
|
268
|
-
static CONTROL: typeof CONTROL;
|
|
269
|
-
|
|
270
|
-
/** Use symbol to access current state of a model. */
|
|
271
|
-
static STATE: typeof STATE;
|
|
272
|
-
|
|
273
|
-
/** Use symbol to access current subscriber of a model in a live context (e.g. hook or effect). */
|
|
274
|
-
static LOCAL: typeof LOCAL;
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Creates a new instance of this controller.
|
|
278
|
-
*
|
|
279
|
-
* Beyond `new this(...)`, method will activate managed-state.
|
|
280
|
-
*
|
|
281
|
-
* @param args - arguments sent to constructor
|
|
282
|
-
*/
|
|
283
|
-
static create <T extends Class> (this: T, ...args: ConstructorParameters<T>): InstanceOf<T>;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* **React Hook** - Spawn and maintain a controller from within a component.
|
|
287
|
-
*
|
|
288
|
-
* Differs from `use()` in lacking subscription and lifecycle events.
|
|
289
|
-
* Much more efficient if you don't need hook-based features.
|
|
290
|
-
*/
|
|
291
|
-
static new <T extends Class> (this: T, ...args: ConstructorParameters<T>): InstanceOf<T>;
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* **React Hook** - Create and attach an instance of this controller a react component.
|
|
295
|
-
*
|
|
296
|
-
* Note: Model will be destroyed when ambient component unmounts!
|
|
297
|
-
*
|
|
298
|
-
* @param args - Arguments passed to constructor of `this`
|
|
299
|
-
*/
|
|
300
|
-
static use <T extends Class> (this: T, ...args: ConstructorParameters<T>): InstanceOf<T>;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* **React Hook** - Similar to `use`, will instanciate a controller bound to ambient component.
|
|
304
|
-
* Accepts an object of values which are injected into controller prior to activation.
|
|
305
|
-
*
|
|
306
|
-
* @param data - Data to be applied to controller upon creation.
|
|
307
|
-
*/
|
|
308
|
-
static uses <T extends Class, I extends InstanceOf<T>, D extends Partial<I>> (this: T, data: D): I;
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* **React Hook** - Similar to `uses`, will instanciate a controller includive of given data.
|
|
312
|
-
* This controller however will remain syncronized with input data at all times.
|
|
313
|
-
* Changes to input data between renders are captured and included in state/event stream.
|
|
314
|
-
*
|
|
315
|
-
* @param data - Data to be observed by controller.
|
|
316
|
-
*/
|
|
317
|
-
static using <T extends Class, I extends InstanceOf<T>, D extends Partial<I>> (this: T, data: D): I;
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* **React Hook** - Fetch most instance of this controller from context, if it exists.
|
|
321
|
-
*
|
|
322
|
-
* @param expect - If true, will throw where controller cannot be found. Otherwise, may return undefined.
|
|
323
|
-
*/
|
|
324
|
-
static get <T extends Class> (this: T, expect?: boolean): InstanceOf<T> | undefined;
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* **React Hook** - Fetch most instance of this controller from context.
|
|
328
|
-
*
|
|
329
|
-
* @param expect - Will throw if controller cannot be found.
|
|
330
|
-
*/
|
|
331
|
-
static get <T extends Class> (this: T, expect: true): InstanceOf<T>;
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* **React Hook** - Fetch specific value from instance of this controller in context.
|
|
335
|
-
*/
|
|
336
|
-
static get <T extends Class, I extends InstanceOf<T>, K extends Model.Fields<I>> (this: T, key: K): I[K];
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* **React Hook** - Fetch specific value from instance of this controller in context.
|
|
340
|
-
*/
|
|
341
|
-
static get <T extends Class, I extends InstanceOf<T>, K extends Model.SelectField<I>> (this: T, key?: K): ReturnType<K>;
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* **React Hook** - Fetch and subscribe to instance of this controller within ambient component.
|
|
345
|
-
*/
|
|
346
|
-
static tap <T extends Class> (this: T): InstanceOf<T>;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* **React Hook** - Fetch and subscribe to a value on applicable instance within ambient component.
|
|
350
|
-
*/
|
|
351
|
-
static tap <T extends Class, I extends InstanceOf<T>, K extends Model.Fields<I>> (this: T, key: K, expect?: boolean): I[K];
|
|
352
|
-
static tap <T extends Class, I extends InstanceOf<T>, K extends Model.SelectField<I>> (this: T, key?: K, expect?: boolean): ReturnType<K>;
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* **React Hook** - Fetch and subscribe to a value on applicable instance within ambient component.
|
|
356
|
-
*
|
|
357
|
-
* **(In Expect Mode)** - Will throw of value is undefined.
|
|
358
|
-
* This makes return type non-nullable and convenient to use without optional chaining.
|
|
359
|
-
*/
|
|
360
|
-
static tap <T extends Class, I extends InstanceOf<T>, K extends Model.Fields<I>> (this: T, key: K, expect: true): Exclude<I[K], undefined>;
|
|
361
|
-
static tap <T extends Class, I extends InstanceOf<T>, K extends Model.SelectField<I>> (this: T, key: K, expect: true): Exclude<ReturnType<K>, undefined>;
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* **React Hook** - Attach to instance of this controller within ambient component.
|
|
365
|
-
*
|
|
366
|
-
* This method will fire lifecycle events on given controller.
|
|
367
|
-
*
|
|
368
|
-
* @param id - Argument passed to controller-lifecycle methods. Use to identify the consumer.
|
|
369
|
-
*/
|
|
370
|
-
static tag <T extends Class, I extends InstanceOf<T>> (this: T, id?: Key): I;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* **React Hook** - Attach to instance of this controller within ambient component.
|
|
374
|
-
*
|
|
375
|
-
* This method will fire lifecycle events on given controller.
|
|
376
|
-
*
|
|
377
|
-
* @param idFactory - Will be invoked with fetched instance. Use this to register a tag as-needed.
|
|
378
|
-
*/
|
|
379
|
-
static tag <T extends Class, I extends InstanceOf<T>> (this: T, idFactory: (on: I) => Key | void): I;
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* **React Hook** - Fetch and subscribe to *class itself* within a component.
|
|
383
|
-
*
|
|
384
|
-
* This allows you to do pretty meta stuff.
|
|
385
|
-
*
|
|
386
|
-
* Documentation TBD.
|
|
387
|
-
*/
|
|
388
|
-
static meta <T extends Class>(this: T): T;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* **React Hook** - Fetch and subscribe to value defined on class itself using selectors.
|
|
392
|
-
*
|
|
393
|
-
* Documentation TBD.
|
|
394
|
-
*/
|
|
395
|
-
static meta <T extends Class, K extends Model.SelectField<T>> (this: T, key?: K): ReturnType<K>;
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* **React Hook** - Locate most relevant instance of this type in context.
|
|
399
|
-
*/
|
|
400
|
-
static find <T extends Class>(this: T): InstanceOf<T>;
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Static equivalent of `x instanceof this`.
|
|
404
|
-
*
|
|
405
|
-
* Will determine if provided class is a subtype of this one.
|
|
406
|
-
*/
|
|
407
|
-
static isTypeof <T extends Class>(this: T, subject: any): subject is T;
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Retreives parent inherited by this class, unless it is base `Model`.
|
|
411
|
-
*/
|
|
412
|
-
static inherits: typeof Model | undefined;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
export class Singleton extends Model {
|
|
416
|
-
/** Current instance of this controller accessable anywhere. */
|
|
417
|
-
static current?: Singleton;
|
|
418
|
-
|
|
419
|
-
/** Destroy current instance of Singleton, if it exists. */
|
|
420
|
-
static reset(): void;
|
|
421
|
-
}
|
package/types/selector.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export namespace Selector {
|
|
2
|
-
/**
|
|
3
|
-
* Shallow-recursive clone of source object.
|
|
4
|
-
* Accumulates keys by property access.
|
|
5
|
-
*
|
|
6
|
-
* For every key:
|
|
7
|
-
* - add key to register
|
|
8
|
-
* - delete key from object
|
|
9
|
-
* - return object
|
|
10
|
-
*/
|
|
11
|
-
type Object<T extends {} = {}, KS extends keyof T = never> = {
|
|
12
|
-
[K in Exclude<keyof T, KS>]: Object<T, KS | K>
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type Keys<S extends Object> =
|
|
16
|
-
S extends Object<any, infer I> ? I : never;
|
|
17
|
-
|
|
18
|
-
type Values<S extends Object> =
|
|
19
|
-
S extends Object<infer T, infer I> ? T[I] : never;
|
|
20
|
-
|
|
21
|
-
export type Function<T> =
|
|
22
|
-
(selector: Object<T>) => Object<T, keyof T>;
|
|
23
|
-
|
|
24
|
-
export type From<F extends Function<any>> =
|
|
25
|
-
F extends (spy: any) => infer R ? Keys<R> : never;
|
|
26
|
-
|
|
27
|
-
export type Gets<F extends Function<any>> =
|
|
28
|
-
F extends (spy: any) => infer R ? Values<R> : never;
|
|
29
|
-
}
|
package/types/types.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type Key = string | symbol | number;
|
|
2
|
-
export type Async = (...args: any[]) => Promise<any>;
|
|
3
|
-
export type BunchOf<T> = { [key: string]: T };
|
|
4
|
-
|
|
5
|
-
export type Class = new (...args: any[]) => any;
|
|
6
|
-
export type InstanceOf<T> = T extends { prototype: infer U } ? U : never;
|
|
7
|
-
export type IfApplicable<T extends {}, K> = K extends keyof T ? T[K] : undefined;
|
|
8
|
-
|
|
9
|
-
export type Callback = () => void;
|
|
10
|
-
export type RequestCallback = (keys?: string[]) => void;
|
|
11
|
-
export type EffectCallback<T, A = T> = (this: T, argument: A) => Callback | Promise<any> | void;
|
|
12
|
-
export type UpdateCallback<T, P> = (this: T, value: IfApplicable<T, P>, changed: P) => void;
|
|
13
|
-
|
|
14
|
-
export type RefFunction = (e: HTMLElement | null) => void;
|