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