@expressive/mvc 0.15.2 → 0.17.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 +108 -153
- package/lib/index.esm.js +550 -555
- package/lib/index.js +549 -559
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,15 @@ type InstanceOf<T> = T extends { prototype: infer U } ? U : never;
|
|
|
7
7
|
/** Type may not be undefined - instead will be null. */
|
|
8
8
|
type NoVoid<T> = T extends undefined ? null : T;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type OptionalValues<T extends {}> = {
|
|
11
|
+
[P in Model.Key<T>]: T[P] | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type NonOptionalValues<T extends {}> = {
|
|
15
|
+
[P in Model.Key<T>]: Exclude<T[P], undefined>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type Listener = {
|
|
11
19
|
commit(): void;
|
|
12
20
|
release(): void;
|
|
13
21
|
};
|
|
@@ -17,17 +25,20 @@ declare namespace Subscriber {
|
|
|
17
25
|
declare class Subscriber<T extends {} = any> {
|
|
18
26
|
parent: Control<T>;
|
|
19
27
|
onUpdate: Subscriber.OnEvent;
|
|
28
|
+
strict?: boolean | undefined;
|
|
20
29
|
proxy: T;
|
|
21
|
-
|
|
30
|
+
clear: () => void;
|
|
22
31
|
latest?: Model.Event<T>[];
|
|
23
32
|
active: boolean;
|
|
24
33
|
dependant: Set<Listener>;
|
|
25
|
-
watch: Map<any, boolean | (() =>
|
|
26
|
-
constructor(parent: Control<T>, onUpdate: Subscriber.OnEvent);
|
|
34
|
+
watch: Map<any, boolean | (() => boolean | void)>;
|
|
35
|
+
constructor(parent: Control<T>, onUpdate: Subscriber.OnEvent, strict?: boolean | undefined);
|
|
27
36
|
get using(): Model.Key<T>[];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
apply(values: Model.Compat<T>, keys?: Model.Key<T>[]): void;
|
|
38
|
+
follow(key: any, value?: boolean | (() => boolean | void)): void;
|
|
39
|
+
commit(): void;
|
|
40
|
+
release(): void;
|
|
41
|
+
private notify;
|
|
31
42
|
}
|
|
32
43
|
|
|
33
44
|
declare const LOCAL = "$debug local";
|
|
@@ -40,7 +51,7 @@ declare const Debug: {
|
|
|
40
51
|
readonly STATE: "$debug state";
|
|
41
52
|
readonly UPDATE: "$debug update";
|
|
42
53
|
};
|
|
43
|
-
|
|
54
|
+
type Debug<T extends {}> = T & {
|
|
44
55
|
/** Controller for this instance. */
|
|
45
56
|
[CONTROL]?: Control<T>;
|
|
46
57
|
/** Current subscriber (if present) while used in a live context (e.g. hook or effect). */
|
|
@@ -62,7 +73,7 @@ declare namespace Model {
|
|
|
62
73
|
/** Including but not limited to T. */
|
|
63
74
|
type Extends<T> = T | (string & Record<never, never>);
|
|
64
75
|
/** Any typeof Model, using class constructor as the reference. */
|
|
65
|
-
export type Type<T extends Model = Model> = abstract new (...args: any[]) => T;
|
|
76
|
+
export type Type<T extends Model = Model> = (abstract new (...args: any[]) => T) & typeof Model;
|
|
66
77
|
/** A typeof Model, specifically one which may be created without arguments. */
|
|
67
78
|
export type New<T extends Model = Model> = (new () => T) & typeof Model;
|
|
68
79
|
export type Effect<T> = (this: T, argument: T) => Callback | Promise<any> | void;
|
|
@@ -111,6 +122,7 @@ declare namespace Model {
|
|
|
111
122
|
export type Export<T> = {
|
|
112
123
|
[P in Key<T>]: Value<T[P]>;
|
|
113
124
|
};
|
|
125
|
+
export type FindFunction = <T extends Model>(type: Model.Type<T>, relativeTo: Model, required: boolean) => (_refresh: (x: T) => void) => T | undefined;
|
|
114
126
|
}
|
|
115
127
|
declare class Model {
|
|
116
128
|
/**
|
|
@@ -182,42 +194,39 @@ declare class Control<T extends {} = any> {
|
|
|
182
194
|
followers: Set<Model.Control.OnSync<any>>;
|
|
183
195
|
latest?: Model.Event<T>[];
|
|
184
196
|
constructor(subject: T);
|
|
185
|
-
subscribe(callback: Subscriber.OnEvent<T>): Model.Subscriber<T>;
|
|
186
197
|
watch(key: keyof T & string): void;
|
|
187
198
|
addListener(listener: Control.OnSync<T>): () => void;
|
|
188
199
|
ref<K extends Model.Key<T>>(key: K, handler?: (this: T, value: T[K]) => boolean | void): (value: any) => void;
|
|
189
200
|
update(key: Model.Key<T>): void;
|
|
190
201
|
clear(): void;
|
|
202
|
+
static get: typeof controller;
|
|
203
|
+
static for: typeof control;
|
|
204
|
+
}
|
|
205
|
+
declare function controller<T extends Model>(from: T): Control<T> | undefined;
|
|
206
|
+
declare namespace control {
|
|
207
|
+
/**
|
|
208
|
+
* Callback for Controller.for() static method.
|
|
209
|
+
* Returned callback is forwarded.
|
|
210
|
+
*/
|
|
211
|
+
type OnReady<T extends Model> = (control: Control<T>) => Callback | void;
|
|
191
212
|
}
|
|
213
|
+
declare function control<T extends Model>(subject: T): Control<T>;
|
|
214
|
+
declare function control<T extends Model>(subject: T, cb: control.OnReady<T>): Callback;
|
|
192
215
|
|
|
193
216
|
/**
|
|
194
217
|
* Property initializer, will run upon instance creation.
|
|
195
218
|
* Optional returned callback will run when once upon first access.
|
|
196
219
|
*/
|
|
197
|
-
|
|
220
|
+
type Instruction<T> = (this: Control, key: string, thisArg: Control) => Instruction.Getter<T> | Instruction.Descriptor<T> | void;
|
|
198
221
|
declare namespace Instruction {
|
|
199
222
|
type Getter<T> = (within?: Subscriber) => T;
|
|
200
223
|
type Setter<T> = (value: T) => boolean | void;
|
|
201
|
-
type Runner
|
|
224
|
+
type Runner = (on: Control, key: string) => Instruction.Descriptor<any> | undefined;
|
|
202
225
|
interface Descriptor<T> {
|
|
203
|
-
configurable?: boolean;
|
|
204
226
|
enumerable?: boolean;
|
|
205
227
|
value?: T;
|
|
206
|
-
writable?: boolean;
|
|
207
228
|
get?: Getter<T>;
|
|
208
229
|
set?: Setter<T> | false;
|
|
209
|
-
suspend?: boolean;
|
|
210
|
-
destroy?: () => void;
|
|
211
|
-
}
|
|
212
|
-
interface ExplicitDescriptor extends PropertyDescriptor {
|
|
213
|
-
explicit: true;
|
|
214
|
-
}
|
|
215
|
-
interface RecursiveDescriptor<T> {
|
|
216
|
-
recursive: true;
|
|
217
|
-
enumerable?: boolean;
|
|
218
|
-
value?: T;
|
|
219
|
-
set?: Setter<T> | false;
|
|
220
|
-
suspend?: boolean;
|
|
221
230
|
}
|
|
222
231
|
}
|
|
223
232
|
/**
|
|
@@ -226,7 +235,7 @@ declare namespace Instruction {
|
|
|
226
235
|
*/
|
|
227
236
|
declare function add<T = any>(instruction: Instruction<any>, label?: string): T;
|
|
228
237
|
|
|
229
|
-
|
|
238
|
+
type Async<T = any> = (...args: any[]) => Promise<T>;
|
|
230
239
|
/**
|
|
231
240
|
* Sets an exotic method with managed ready-state. Property accepts an async function.
|
|
232
241
|
*
|
|
@@ -246,65 +255,35 @@ declare function run<S>(action: Async<S>): typeof action & {
|
|
|
246
255
|
|
|
247
256
|
declare namespace get {
|
|
248
257
|
type Function<T, S = any> = (this: S, on: S) => T;
|
|
249
|
-
type Factory<
|
|
258
|
+
type Factory<R, T> = (this: T, property: string, on: T) => Function<R, T>;
|
|
250
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Fetches and assigns the controller which spawned this host.
|
|
262
|
+
* When parent assigns an instance via `use()` directive, it
|
|
263
|
+
* will be made available to child upon this request.
|
|
264
|
+
*
|
|
265
|
+
* @param Type - Type of controller compatible with this class.
|
|
266
|
+
* @param required - Throw if controller is created independantly.
|
|
267
|
+
*/
|
|
268
|
+
declare function get<T extends Model>(Type: Model.Type<T>, required?: true): T;
|
|
269
|
+
declare function get<T extends Model>(Type: Model.Type<T>, required: boolean): T | undefined;
|
|
270
|
+
declare function get<R, T extends Model>(Type: Model.Type<T>, compute: (this: T, on: T) => R): Exclude<R, undefined>;
|
|
271
|
+
declare function get<R, T extends Model>(Type: Model.Type<T>, compute: (this: T, on: T) => R): R;
|
|
251
272
|
/**
|
|
252
273
|
* Implement a computed value; output will be generated by provided function.
|
|
253
274
|
*
|
|
254
275
|
* @param source - Source model from which computed value will be a subscriber.
|
|
255
276
|
* @param compute - Compute function. Bound to a subscriber-proxy of source, returns output value. Will update automatically as input values change.
|
|
256
|
-
* @param suspend - Value will throw suspense when evaulating to undefined.
|
|
257
277
|
*/
|
|
258
|
-
declare function get<R, T>(source: T, compute: (this: T, on: T) => R
|
|
259
|
-
declare function get<R, T>(source: T, compute: (this: T, on: T) => R
|
|
278
|
+
declare function get<R, T>(source: T, compute: (this: T, on: T) => R): Exclude<R, undefined>;
|
|
279
|
+
declare function get<R, T>(source: T, compute: (this: T, on: T) => R): R;
|
|
260
280
|
/**
|
|
261
281
|
* Implement a computed value; output is returned by function from provided factory.
|
|
262
282
|
*
|
|
263
283
|
* @param compute - Factory function to generate a getter to subscribe dependancies.
|
|
264
|
-
* @param suspend - Value will throw suspense when evaulating to undefined.
|
|
265
284
|
*/
|
|
266
|
-
declare function get<R, T>(compute: (property: string, on: T) => (this: T, state: T) => R
|
|
267
|
-
declare function get<R, T>(compute: (property: string, on: T) => (this: T, state: T) => R
|
|
268
|
-
/**
|
|
269
|
-
* Set property with an async function.
|
|
270
|
-
*
|
|
271
|
-
* Property cannot be accessed until factory resolves, yeilding a result.
|
|
272
|
-
* If accessed while processing, React Suspense will be thrown.
|
|
273
|
-
*
|
|
274
|
-
* - `required: true` (default) -
|
|
275
|
-
* Run factory immediately upon creation of model instance.
|
|
276
|
-
* - `required: false` -
|
|
277
|
-
* Run factory only if/when accessed.
|
|
278
|
-
* Value will always throw suspense at least once - use with caution.
|
|
279
|
-
*
|
|
280
|
-
* @param factory - Callback run to derrive property value.
|
|
281
|
-
* @param required - (default: true) Run factory immediately on creation, otherwise on access.
|
|
282
|
-
*/
|
|
283
|
-
declare function get<T>(factory: get.Factory<Promise<T>>, required: false): T | undefined;
|
|
284
|
-
declare function get<T, S>(factory: get.Factory<Promise<T>, S>, required: false): T | undefined;
|
|
285
|
-
declare function get<T>(factory: get.Factory<Promise<T>>, required?: boolean): T;
|
|
286
|
-
declare function get<T, S>(factory: get.Factory<Promise<T>, S>, required?: boolean): T;
|
|
287
|
-
/**
|
|
288
|
-
* Set property with a factory function.
|
|
289
|
-
*
|
|
290
|
-
* - `required: true` (default) -
|
|
291
|
-
* Run factory immediately upon creation of model instance.
|
|
292
|
-
* - `required: false` -
|
|
293
|
-
* Run factory only if/when accessed.
|
|
294
|
-
* Value will always throw suspense at least once - use with caution.
|
|
295
|
-
*
|
|
296
|
-
* @param factory - Callback run to derrive property value.
|
|
297
|
-
* @param required - (default: true) Run factory immediately on creation, otherwise on access.
|
|
298
|
-
*/
|
|
299
|
-
declare function get<T>(factory: get.Factory<T>, required: false): T | undefined;
|
|
300
|
-
declare function get<T, S>(factory: get.Factory<T, S>, required: false): T | undefined;
|
|
301
|
-
declare function get<T>(factory: get.Factory<T>, required?: boolean): T;
|
|
302
|
-
declare function get<T, S>(factory: get.Factory<T, S>, required?: boolean): T;
|
|
303
|
-
/**
|
|
304
|
-
* Assign a property with result of a promise.
|
|
305
|
-
*/
|
|
306
|
-
declare function get<T>(factory: Promise<T>, required: false): T | undefined;
|
|
307
|
-
declare function get<T>(factory: Promise<T>, required?: boolean): T;
|
|
285
|
+
declare function get<R, T>(compute: (property: string, on: T) => (this: T, state: T) => R): Exclude<R, undefined>;
|
|
286
|
+
declare function get<R, T>(compute: (property: string, on: T) => (this: T, state: T) => R): R;
|
|
308
287
|
|
|
309
288
|
declare namespace ref {
|
|
310
289
|
type Callback<T, S = any> = (this: S, argument: T) => ((next: T) => void) | Promise<void> | void | boolean;
|
|
@@ -351,6 +330,7 @@ declare function ref<T, S>(callback?: ref.Callback<T, S>): ref.Object<T>;
|
|
|
351
330
|
|
|
352
331
|
declare namespace set {
|
|
353
332
|
type Callback<T, S = any> = (this: S, argument: T) => ((next: T) => void) | Promise<any> | void | boolean;
|
|
333
|
+
type Factory<T, S = unknown> = (this: S, key: string, thisArg: S) => T;
|
|
354
334
|
}
|
|
355
335
|
/**
|
|
356
336
|
* Set property with a placeholder.
|
|
@@ -359,15 +339,50 @@ declare namespace set {
|
|
|
359
339
|
* `Promise`/`Error` (ala: [Suspense](https://reactjs.org/docs/concurrent-mode-suspense.html)) will be thrown.
|
|
360
340
|
*/
|
|
361
341
|
declare function set<T = any>(): T;
|
|
362
|
-
|
|
363
|
-
|
|
342
|
+
/**
|
|
343
|
+
* Set property with an async function.
|
|
344
|
+
*
|
|
345
|
+
* Property cannot be accessed until factory resolves, yeilding a result.
|
|
346
|
+
* If accessed while processing, React Suspense will be thrown.
|
|
347
|
+
*
|
|
348
|
+
* - `required: true` (default) -
|
|
349
|
+
* Run factory immediately upon creation of model instance.
|
|
350
|
+
* - `required: false` -
|
|
351
|
+
* Run factory only if/when accessed.
|
|
352
|
+
* Value will always throw suspense at least once - use with caution.
|
|
353
|
+
*
|
|
354
|
+
* @param factory - Callback run to derrive property value.
|
|
355
|
+
* @param required - (default: true) Run factory immediately on creation, otherwise on access.
|
|
356
|
+
*/
|
|
357
|
+
declare function set<T>(factory: set.Factory<Promise<T>>, required: false): T | undefined;
|
|
358
|
+
declare function set<T, S>(factory: set.Factory<Promise<T>, S>, required: false): T | undefined;
|
|
359
|
+
declare function set<T>(factory: set.Factory<Promise<T>>, required?: boolean): T;
|
|
360
|
+
declare function set<T, S>(factory: set.Factory<Promise<T>, S>, required?: boolean): T;
|
|
361
|
+
/**
|
|
362
|
+
* Set property with a factory function.
|
|
363
|
+
*
|
|
364
|
+
* - `required: true` (default) -
|
|
365
|
+
* Run factory immediately upon creation of model instance.
|
|
366
|
+
* - `required: false` -
|
|
367
|
+
* Run factory only if/when accessed.
|
|
368
|
+
* Value will always throw suspense at least once - use with caution.
|
|
369
|
+
*
|
|
370
|
+
* @param factory - Callback run to derrive property value.
|
|
371
|
+
* @param required - (default: true) Run factory immediately on creation, otherwise on access.
|
|
372
|
+
*/
|
|
373
|
+
declare function set<T>(factory: set.Factory<T>, required: false): T | undefined;
|
|
374
|
+
declare function set<T, S>(factory: set.Factory<T, S>, required: false): T | undefined;
|
|
375
|
+
declare function set<T>(factory: set.Factory<T>, required?: boolean): T;
|
|
376
|
+
declare function set<T, S>(factory: set.Factory<T, S>, required?: boolean): T;
|
|
377
|
+
declare function set<T>(factory: Promise<T>, required: false): T | undefined;
|
|
378
|
+
declare function set<T>(factory: Promise<T>, required?: boolean): T;
|
|
364
379
|
declare function set<T>(value: undefined, onUpdate: set.Callback<T>): T;
|
|
365
380
|
declare function set<T, S>(value: undefined, onUpdate: set.Callback<T, S>): T;
|
|
366
381
|
declare function set<T>(value: T, onUpdate: set.Callback<T>): T;
|
|
367
382
|
declare function set<T, S>(value: T, onUpdate: set.Callback<T, S>): T;
|
|
368
383
|
|
|
369
|
-
|
|
370
|
-
|
|
384
|
+
type MapFunction<T, R> = T extends Map<infer K, infer V> ? (value: V, key: K, map: T) => R | void : T extends Set<infer K> ? (value: K, key: K, set: T) => R | void : never;
|
|
385
|
+
type Managed<T> = Exclude<T, "forEach"> & {
|
|
371
386
|
from?: T;
|
|
372
387
|
forEach<R>(mapFunction: MapFunction<T, R>, thisArg?: any): Exclude<R, undefined>[] | void;
|
|
373
388
|
};
|
|
@@ -407,17 +422,6 @@ declare function use<T extends {}>(from: () => T, callback?: (i: T) => void): T;
|
|
|
407
422
|
*/
|
|
408
423
|
declare function use<T extends {}>(peer: T, callback?: (i: T) => void): T;
|
|
409
424
|
|
|
410
|
-
/**
|
|
411
|
-
* Fetches and assigns the controller which spawned this host.
|
|
412
|
-
* When parent assigns an instance via `use()` directive, it
|
|
413
|
-
* will be made available to child upon this request.
|
|
414
|
-
*
|
|
415
|
-
* @param Type - Type of controller compatible with this class.
|
|
416
|
-
* @param required - Throw if controller is created independantly.
|
|
417
|
-
*/
|
|
418
|
-
declare function has<T extends Model>(Type: Model.Type<T>, required: false): T | undefined;
|
|
419
|
-
declare function has<T extends Model>(Type: Model.Type<T>, required?: true): T;
|
|
420
|
-
|
|
421
425
|
declare namespace MVC {
|
|
422
426
|
type EffectCallback<T = MVC> = (found: T) => Callback | void;
|
|
423
427
|
type ForceUpdate = {
|
|
@@ -466,52 +470,31 @@ declare class MVC extends Model {
|
|
|
466
470
|
* Returned function is called on unmount.
|
|
467
471
|
*/
|
|
468
472
|
static get<I extends MVC>(this: Model.Type<I>, effectCallback: MVC.EffectCallback<I>): I | undefined;
|
|
469
|
-
/**
|
|
470
|
-
* **React Hook** - Fetch specific value from instance of this controller in context.
|
|
471
|
-
*/
|
|
472
|
-
static get<I extends MVC, K extends Model.Key<I>>(this: Model.Type<I>, key: K): I[K];
|
|
473
473
|
/**
|
|
474
474
|
* **React Hook** - Fetch and subscribe to instance of this controller within ambient component.
|
|
475
475
|
*/
|
|
476
476
|
static tap<T extends MVC>(this: Model.Type<T>): T;
|
|
477
|
-
static tap<T extends MVC,
|
|
478
|
-
static tap<T extends MVC,
|
|
479
|
-
static tap<T extends MVC, R>(this: Model.Type<T>,
|
|
480
|
-
static tap<T extends MVC, R>(this: Model.Type<T>,
|
|
477
|
+
static tap<T extends MVC, R extends readonly unknown[] | []>(this: Model.Type<T>, compute: MVC.TapCallback<T, R | (() => R)>, expect?: boolean): R;
|
|
478
|
+
static tap<T extends MVC, R extends readonly unknown[] | []>(this: Model.Type<T>, compute: MVC.TapCallback<T, Promise<R> | (() => R) | null>, expect?: boolean): R | null;
|
|
479
|
+
static tap<T extends MVC, R extends readonly unknown[] | []>(this: Model.Type<T>, compute: MVC.TapCallback<T, Promise<R> | R>, expect: true): Exclude<R, undefined>;
|
|
480
|
+
static tap<T extends MVC, R>(this: Model.Type<T>, init: MVC.TapCallback<T, () => R>): NoVoid<R>;
|
|
481
|
+
static tap<T extends MVC, R>(this: Model.Type<T>, init: MVC.TapCallback<T, (() => R) | null>): NoVoid<R> | null;
|
|
481
482
|
static tap<T extends MVC, R>(this: Model.Type<T>, compute: MVC.TapCallback<T, Promise<R> | R>, expect: true): Exclude<R, undefined>;
|
|
482
483
|
static tap<T extends MVC, R>(this: Model.Type<T>, compute: MVC.TapCallback<T, Promise<R>>, expect?: boolean): NoVoid<R> | null;
|
|
483
484
|
static tap<T extends MVC, R>(this: Model.Type<T>, compute: MVC.TapCallback<T, R>, expect?: boolean): NoVoid<R>;
|
|
485
|
+
static tap<T extends MVC>(this: Model.Type<T>, expect: true): NonOptionalValues<T>;
|
|
486
|
+
static tap<T extends MVC>(this: Model.Type<T>, expect?: boolean): OptionalValues<T>;
|
|
484
487
|
static use<I extends MVC>(this: Model.Type<I>, watch: Model.Key<I>[], callback?: (instance: I) => void): I;
|
|
485
488
|
static use<I extends MVC>(this: Model.Type<I>, callback?: (instance: I) => void): I;
|
|
486
489
|
static use<I extends MVC>(this: Model.Type<I>, apply: Model.Compat<I>, keys?: Model.Event<I>[]): I;
|
|
487
|
-
static meta<T extends Class>(this: T): T;
|
|
488
|
-
static meta<T extends Class
|
|
489
|
-
static meta<T extends Class
|
|
490
|
-
static meta<T, M extends Class>(this: M, from: (this: M, state: M) => Promise<T>, expect: true): Exclude<T, undefined>;
|
|
491
|
-
static meta<T, M extends Class>(this: M, from: (this: M, state: M) => Promise<T>, expect?: boolean): T;
|
|
492
|
-
static meta<T, M extends Class>(this: M, from: (this: M, state: M) => T, expect: true): Exclude<T, undefined>;
|
|
493
|
-
static meta<T, M extends Class>(this: M, from: (this: M, state: M) => T, expect?: boolean): T;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
declare function useContext<T extends Model>(Type: Model.Type<T>, required: false): T | undefined;
|
|
497
|
-
declare function useContext<T extends Model>(Type: Model.Type<T>, required?: boolean): T;
|
|
498
|
-
|
|
499
|
-
declare function useNew<T extends Model>(source: Model.New<T> | (() => T), callback?: (instance: T) => void): T;
|
|
500
|
-
declare function useNew<T extends Model>(source: Model.New<T> | (() => T), watch: Model.Key<T>[], callback?: (instance: T) => void): T;
|
|
501
|
-
declare function useNew<T extends Model>(source: Model.New<T> | (() => T), apply: Model.Compat<T>, keys?: Model.Event<T>[]): T;
|
|
502
|
-
|
|
503
|
-
declare namespace useTap {
|
|
504
|
-
type Source<T extends Model> = T | Model.Type<T> | (() => T | Model.Type<T>);
|
|
505
|
-
type Callback<T extends Model, R> = (this: T, model: T, update: MVC.ForceUpdate) => R;
|
|
490
|
+
protected static meta<T extends Class>(this: T): T;
|
|
491
|
+
protected static meta<T extends Class>(this: T, expect: true): NonOptionalValues<T>;
|
|
492
|
+
protected static meta<T extends Class>(this: T, expect?: boolean): OptionalValues<T>;
|
|
493
|
+
protected static meta<T, M extends Class>(this: M, from: (this: M, state: M) => Promise<T>, expect: true): Exclude<T, undefined>;
|
|
494
|
+
protected static meta<T, M extends Class>(this: M, from: (this: M, state: M) => Promise<T>, expect?: boolean): T;
|
|
495
|
+
protected static meta<T, M extends Class>(this: M, from: (this: M, state: M) => T, expect: true): Exclude<T, undefined>;
|
|
496
|
+
protected static meta<T, M extends Class>(this: M, from: (this: M, state: M) => T, expect?: boolean): T;
|
|
506
497
|
}
|
|
507
|
-
declare function useTap<T extends Model>(source: useTap.Source<T>): T;
|
|
508
|
-
declare function useTap<T extends Model, K extends Model.Key<T>>(source: useTap.Source<T>, path: K, expect: true): Exclude<T[K], undefined>;
|
|
509
|
-
declare function useTap<T extends Model, K extends Model.Key<T>>(source: useTap.Source<T>, path: K, expect?: boolean): NoVoid<T[K]>;
|
|
510
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, connect: useTap.Callback<T, () => R>): NoVoid<R>;
|
|
511
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, connect: useTap.Callback<T, (() => R) | null>): NoVoid<R> | null;
|
|
512
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: useTap.Callback<T, Promise<R> | R>, expect: true): Exclude<R, undefined>;
|
|
513
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: useTap.Callback<T, Promise<R>>, expect?: boolean): NoVoid<R> | null;
|
|
514
|
-
declare function useTap<T extends Model, R>(source: useTap.Source<T>, compute: useTap.Callback<T, R>, expect?: boolean): NoVoid<R>;
|
|
515
498
|
|
|
516
499
|
declare namespace Consumer {
|
|
517
500
|
type HasProps<E extends Class> = {
|
|
@@ -577,32 +560,4 @@ declare class Global extends MVC {
|
|
|
577
560
|
static keepAlive: boolean;
|
|
578
561
|
}
|
|
579
562
|
|
|
580
|
-
|
|
581
|
-
type Callback<T extends Model> = (instance: T | undefined) => void | boolean;
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Find and attach most applicable instance of Model via context.
|
|
585
|
-
*
|
|
586
|
-
* Host controller will search element-hierarchy relative to where it spawned.
|
|
587
|
-
*
|
|
588
|
-
* @param Type - Type of model to find from context
|
|
589
|
-
* @param callback -
|
|
590
|
-
* - Invoked after context is scanned, is passed result - either found or undefined.
|
|
591
|
-
* - If argument is inadequate, but required, your implemention should simply throw.
|
|
592
|
-
* - If inadequate and not required, conditionally return false.
|
|
593
|
-
*/
|
|
594
|
-
declare function tap<T extends Model>(Type: Model.Type<T>, callback?: (instance?: T) => void | true): T;
|
|
595
|
-
declare function tap<T extends Model>(Type: Model.Type<T>, callback?: (instance?: T) => void | boolean): T | undefined;
|
|
596
|
-
/**
|
|
597
|
-
* Find and attach most applicable instance of Model via context.
|
|
598
|
-
*
|
|
599
|
-
* Expects a `<Provider>` of target controller to exist.
|
|
600
|
-
* Host controller will search element-hierarchy relative to where it spawned.
|
|
601
|
-
*
|
|
602
|
-
* @param Type - Type of controller to attach to property.
|
|
603
|
-
* @param required - Throw if instance of Type cannot be found.
|
|
604
|
-
*/
|
|
605
|
-
declare function tap<T extends Model>(Type: Model.Type<T>, required: true): T;
|
|
606
|
-
declare function tap<T extends Model>(Type: Model.Type<T>, required?: boolean): T | undefined;
|
|
607
|
-
|
|
608
|
-
export { Consumer, Debug, Global, MVC, MVC as Model, Provider, add, MVC as default, get, has, ref, run, set, tap, use, useContext, useNew, useTap };
|
|
563
|
+
export { Consumer, Debug, Global, MVC, MVC as Model, Provider, add, MVC as default, get, ref, run, set, use };
|