@expressive/mvc 1.0.0-beta.36 → 1.0.0-beta.37
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 +582 -0
- package/lib/index.esm.js +693 -757
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +700 -761
- package/lib/index.js.map +1 -1
- package/package.json +9 -8
- package/types/context.d.ts +0 -57
- package/types/index.d.ts +0 -8
- package/types/instructions.d.ts +0 -326
- package/types/lifecycle.d.ts +0 -32
- package/types/model.d.ts +0 -457
- package/types/types.d.ts +0 -4
package/types/model.d.ts
DELETED
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
import { Key } from 'react';
|
|
2
|
-
|
|
3
|
-
import Lifecycle from './lifecycle';
|
|
4
|
-
import { BunchOf, Class, InstanceOf } from './types';
|
|
5
|
-
|
|
6
|
-
type Callback = () => void;
|
|
7
|
-
type Argument<T> = T extends (arg: infer U) => any ? U : never;
|
|
8
|
-
type IfApplicable<T extends {}, K> = K extends keyof T ? T[K] : undefined;
|
|
9
|
-
type Including<T> = T | (string & Record<never, never>);
|
|
10
|
-
|
|
11
|
-
type Thenable<T> = {
|
|
12
|
-
then(onFulfilled: (arg: T) => void): 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 UpdateCallback<T, P> = (this: T, value: IfApplicable<T, P>, changed: P) => void;
|
|
23
|
-
|
|
24
|
-
type EffectCallback<T> = (this: T, argument: T) => Callback | Promise<any> | void;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Property initializer, will run upon instance creation.
|
|
28
|
-
* Optional returned callback will run when once upon first access.
|
|
29
|
-
*/
|
|
30
|
-
type Instruction<T> = (this: Controller, key: string, thisArg: Controller) =>
|
|
31
|
-
void | Instruction.Getter<T> | Instruction.Descriptor<T>;
|
|
32
|
-
|
|
33
|
-
namespace Instruction {
|
|
34
|
-
interface Descriptor<T> {
|
|
35
|
-
configurable?: boolean;
|
|
36
|
-
enumerable?: boolean;
|
|
37
|
-
value?: T;
|
|
38
|
-
writable?: boolean;
|
|
39
|
-
get?(current: T | undefined, within?: Subscriber): T;
|
|
40
|
-
set?(value: T, state: any): boolean | void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type Getter<T> = (state: T | undefined, within?: Subscriber) => T;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Subset of `keyof T` excluding keys defined by base Model */
|
|
47
|
-
type Fields<T, E = Model> = Exclude<keyof T, keyof E>;
|
|
48
|
-
|
|
49
|
-
/** Object containing data found in T. */
|
|
50
|
-
type Entries<T, E = Model> = Pick<T, Fields<T, E>>;
|
|
51
|
-
|
|
52
|
-
/** Actual value stored in state. */
|
|
53
|
-
type Value<R> = R extends Ref<infer T> ? T : R;
|
|
54
|
-
|
|
55
|
-
/** Values from current state of given controller. */
|
|
56
|
-
type State<T, K extends keyof T = Fields<T, Model>> = {
|
|
57
|
-
[P in K]: Value<T[P]>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Object comperable to data found in T. */
|
|
61
|
-
type Compat<T, Exclude = Model> = Partial<Entries<T, Exclude>>;
|
|
62
|
-
|
|
63
|
-
/** Subset of `keyof T` excluding keys defined by base Model, except lifecycle. */
|
|
64
|
-
type Events<T> = Omit<T, Exclude<keyof Model, keyof Lifecycle>>;
|
|
65
|
-
|
|
66
|
-
type EventsCompat<T> = Including<keyof T | keyof Lifecycle>;
|
|
67
|
-
|
|
68
|
-
type Typeof<T, ST, X extends keyof T = Exclude<keyof T, keyof Model>> = {
|
|
69
|
-
[Key in X]: T[Key] extends ST ? Key : never;
|
|
70
|
-
}[X];
|
|
71
|
-
|
|
72
|
-
export namespace Controller {
|
|
73
|
-
type RequestCallback = (keys: readonly string[]) => void;
|
|
74
|
-
|
|
75
|
-
type OnEvent = (key: string, source: Controller) =>
|
|
76
|
-
RequestCallback | undefined;
|
|
77
|
-
|
|
78
|
-
type OnValue = <T>(this: T, value: any, state: T) => boolean | void;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export class Controller {
|
|
82
|
-
state: BunchOf<any>;
|
|
83
|
-
subject: {};
|
|
84
|
-
waiting: Set<Controller.RequestCallback>;
|
|
85
|
-
frame: Set<string>;
|
|
86
|
-
|
|
87
|
-
start(): this;
|
|
88
|
-
|
|
89
|
-
manage(key: string, effect?: Controller.OnValue): void;
|
|
90
|
-
|
|
91
|
-
setter(key: string, effect?: Controller.OnValue): (value: any) => boolean | void;
|
|
92
|
-
|
|
93
|
-
addListener(listener: Controller.OnEvent): Callback;
|
|
94
|
-
|
|
95
|
-
update(key: string, value?: any): void;
|
|
96
|
-
|
|
97
|
-
requestUpdate(): PromiseLike<readonly string[] | false>;
|
|
98
|
-
requestUpdate(strict: true): Promise<readonly string[]>;
|
|
99
|
-
requestUpdate(strict: false): Promise<false>;
|
|
100
|
-
requestUpdate(strict: boolean): Promise<readonly string[] | false>;
|
|
101
|
-
requestUpdate(callback: Controller.RequestCallback): void;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export class Subscriber {
|
|
105
|
-
proxy: any;
|
|
106
|
-
source: any;
|
|
107
|
-
parent: Controller;
|
|
108
|
-
active: boolean;
|
|
109
|
-
listen: Controller.OnEvent;
|
|
110
|
-
dependant: Set<{
|
|
111
|
-
commit(): void;
|
|
112
|
-
release(): void;
|
|
113
|
-
}>;
|
|
114
|
-
|
|
115
|
-
follow(key: string, cb?: Controller.RequestCallback | undefined): void;
|
|
116
|
-
commit(): Callback;
|
|
117
|
-
release(): Callback;
|
|
118
|
-
onUpdate(): void;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
declare const CONTROL: unique symbol;
|
|
123
|
-
declare const WHY: unique symbol;
|
|
124
|
-
declare const LOCAL: unique symbol;
|
|
125
|
-
declare const STATE: unique symbol;
|
|
126
|
-
|
|
127
|
-
export interface Model extends Lifecycle {}
|
|
128
|
-
export abstract class Model {
|
|
129
|
-
/** Controller for this instance. */
|
|
130
|
-
[CONTROL]: Model.Controller;
|
|
131
|
-
|
|
132
|
-
/** Current state of this instance. */
|
|
133
|
-
[STATE]?: Model.State<this>;
|
|
134
|
-
|
|
135
|
-
/** Current subscriber (if present) while used in a live context (e.g. hook or effect). */
|
|
136
|
-
[LOCAL]?: Model.Subscriber;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Last update causing a refresh to subscribers.
|
|
140
|
-
*
|
|
141
|
-
* If accessed directly, will contain all keys from last push.
|
|
142
|
-
* If within a subscribed function, will contain only keys which explicitly caused a refresh.
|
|
143
|
-
**/
|
|
144
|
-
[WHY]?: readonly string[];
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Circular reference to `this` controller.
|
|
148
|
-
*
|
|
149
|
-
* Useful to obtain full reference where one has already destructured.
|
|
150
|
-
*
|
|
151
|
-
* ---
|
|
152
|
-
*
|
|
153
|
-
* **Retrieve root object after destructure:**
|
|
154
|
-
*
|
|
155
|
-
* ```js
|
|
156
|
-
* const { active, get: instance } = MyModel.use();
|
|
157
|
-
* ```
|
|
158
|
-
* Is equivalent to:
|
|
159
|
-
* ```js
|
|
160
|
-
* const instance = MyModel.use();
|
|
161
|
-
* const { active } = instance;
|
|
162
|
-
* ```
|
|
163
|
-
* ---
|
|
164
|
-
*
|
|
165
|
-
* **Access values without watch:**
|
|
166
|
-
*
|
|
167
|
-
* Also useful to "peek" values without indicating you
|
|
168
|
-
* want them watched, via built-in hook.
|
|
169
|
-
*
|
|
170
|
-
* ```js
|
|
171
|
-
* const { firstName, get } = Hello.use();
|
|
172
|
-
*
|
|
173
|
-
* return (
|
|
174
|
-
* <div onClick={() => {
|
|
175
|
-
* alert(`Hello ${firstName} ${get.lastName}`)
|
|
176
|
-
* }}>
|
|
177
|
-
* Hello {firstName}
|
|
178
|
-
* </div>
|
|
179
|
-
* )
|
|
180
|
-
* ```
|
|
181
|
-
* Here, it would be a waste to trigger an update every time lastName changes (say, due to an input).
|
|
182
|
-
* Using `get.lastName` allows us to obtain the value only when needed.
|
|
183
|
-
*/
|
|
184
|
-
get: this;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Circular reference to `this` controller.
|
|
188
|
-
*
|
|
189
|
-
* Useful mnemonic to update values on a controller from within a component.
|
|
190
|
-
*
|
|
191
|
-
* ---
|
|
192
|
-
*
|
|
193
|
-
* ```js
|
|
194
|
-
* const { active, set } = MyToggle.use();
|
|
195
|
-
*
|
|
196
|
-
* return (
|
|
197
|
-
* <div onClick={() => set.active = !active}>
|
|
198
|
-
* Toggle is {active ? "active" : "inactive"}!
|
|
199
|
-
* </div>
|
|
200
|
-
* )
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
set: this;
|
|
204
|
-
|
|
205
|
-
import <O extends Model.Compat<this>> (via: O, select?: string[]): void;
|
|
206
|
-
|
|
207
|
-
export(): Model.State<this>;
|
|
208
|
-
export <P extends Model.Fields<this>> (select: P[]): Model.State<this, P>;
|
|
209
|
-
|
|
210
|
-
update(): PromiseLike<readonly string[] | false>;
|
|
211
|
-
update(strict: true): Promise<readonly string[]>;
|
|
212
|
-
update(strict: false): Promise<false>;
|
|
213
|
-
update(strict: boolean): Promise<readonly string[] | false>;
|
|
214
|
-
|
|
215
|
-
update(keys: Including<Model.Fields<this>>): Thenable<readonly string[]>;
|
|
216
|
-
update(keys: Including<Model.Fields<this>>, callMethod: boolean): PromiseLike<readonly string[]>;
|
|
217
|
-
update<T>(keys: Including<Model.Fields<this>>, argument: T): PromiseLike<readonly string[]>;
|
|
218
|
-
|
|
219
|
-
/*
|
|
220
|
-
Issue with self-reference, using fallback.
|
|
221
|
-
|
|
222
|
-
update(keys: Model.Typeof<this, () => void>, callMethod: boolean): Thenable<string[]>;
|
|
223
|
-
update(keys: Model.SelectTypeof<this, () => void>, callMethod: boolean): Thenable<string[]>;
|
|
224
|
-
|
|
225
|
-
update<T>(keys: Model.Typeof<this, (arg: T) => void>, argument: T): Thenable<string[]>;
|
|
226
|
-
update<T>(keys: Model.SelectTypeof<this, (arg: T) => void>, argument: T): Thenable<string[]>;
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Mark this instance for garbage-collection and send `willDestroy` event to all listeners.
|
|
231
|
-
*
|
|
232
|
-
* Implemented by class in-use, see `Model.willDestroy`.
|
|
233
|
-
*/
|
|
234
|
-
destroy(): void;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Callback for when a controller is fully activated and about to be in use.
|
|
238
|
-
*
|
|
239
|
-
* Invoke after initial state has been locked, and instance is now aware of what values should be tracked.
|
|
240
|
-
*/
|
|
241
|
-
didCreate?(): void;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Callback for when a controller is about to expire.
|
|
245
|
-
*/
|
|
246
|
-
willDestroy?(): void;
|
|
247
|
-
|
|
248
|
-
/** Attaches this controller to a component. */
|
|
249
|
-
tap(): this;
|
|
250
|
-
|
|
251
|
-
/** Tracks specific key of this controller within a component. */
|
|
252
|
-
tap <K extends Model.Fields<this>> (key: K, expect: true): Exclude<this[K], undefined>;
|
|
253
|
-
tap <K extends Model.Fields<this>> (key: K, expect?: boolean): this[K];
|
|
254
|
-
|
|
255
|
-
tap <T> (from: (this: this, state: this) => Promise<T>, expect: true): Exclude<T, undefined>;
|
|
256
|
-
tap <T> (from: (this: this, state: this) => Promise<T>, expect?: boolean): T | undefined;
|
|
257
|
-
|
|
258
|
-
tap <T> (from: (this: this, state: this) => T, expect: true): Exclude<T, undefined>;
|
|
259
|
-
tap <T> (from: (this: this, state: this) => T, expect?: boolean): T;
|
|
260
|
-
|
|
261
|
-
// Keyed
|
|
262
|
-
on <P = Model.EventsCompat<this>> (keys: [], listener: Model.UpdateCallback<this, P>, squash?: false, once?: boolean): Callback;
|
|
263
|
-
on <P extends Model.EventsCompat<this>> (key: P | P[], listener: Model.UpdateCallback<this, P>, squash?: false, once?: boolean): Callback;
|
|
264
|
-
// Squash
|
|
265
|
-
on <P = Model.EventsCompat<this>> (keys: [], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
|
|
266
|
-
on <P extends Model.EventsCompat<this>> (key: P | P[], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
|
|
267
|
-
// Unknown
|
|
268
|
-
on (keys: [], listener: unknown, squash: boolean, once?: boolean): Callback;
|
|
269
|
-
on <P extends Model.EventsCompat<this>> (key: P | P[], listener: unknown, squash: boolean, once?: boolean): Callback;
|
|
270
|
-
|
|
271
|
-
// Keyed
|
|
272
|
-
once <P = Model.EventsCompat<this>> (keys: [], listener: Model.UpdateCallback<this, P>, squash?: false, once?: boolean): Callback;
|
|
273
|
-
once <P extends Model.EventsCompat<this>> (key: P | P[], listener: Model.UpdateCallback<this, P>, squash?: false): Callback;
|
|
274
|
-
// Squash
|
|
275
|
-
once <P = Model.EventsCompat<this>> (keys: [], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
|
|
276
|
-
once <P extends Model.EventsCompat<this>> (key: P | P[], listener: (keys: P[]) => void, squash: true): Callback;
|
|
277
|
-
// Promise
|
|
278
|
-
once <P = Model.EventsCompat<this>> (keys: [], listener: (keys: P[]) => void, squash: true, once?: boolean): Callback;
|
|
279
|
-
once <P extends Model.EventsCompat<this>> (key: P | P[]): Promise<P[]>;
|
|
280
|
-
// Unknown
|
|
281
|
-
once (keys: [], listener: unknown, squash: boolean, once?: boolean): Callback;
|
|
282
|
-
once <P extends Model.EventsCompat<this>> (key: P | P[], listener: unknown, squash: boolean): Callback;
|
|
283
|
-
|
|
284
|
-
effect(callback: Model.EffectCallback<this>): Callback;
|
|
285
|
-
effect(callback: Model.EffectCallback<this>, select: []): Callback;
|
|
286
|
-
effect(callback: Model.EffectCallback<this>, select: (keyof this)[]): Callback;
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* **React Hook** - Attach to instance of this controller within a component.
|
|
290
|
-
*
|
|
291
|
-
* This method will fire lifecycle events on given controller.
|
|
292
|
-
*
|
|
293
|
-
* @param id - Argument passed to controller-lifecycle methods. Use to identify the consumer.
|
|
294
|
-
*/
|
|
295
|
-
tag(id?: any): this;
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* **React Hook** - Subscribe to instance of controller within a component.
|
|
299
|
-
*
|
|
300
|
-
* This method will fire lifecycle events on given controller (as element)..
|
|
301
|
-
*
|
|
302
|
-
* @param idFactory - Will be invoked with fetched instance. Use this to register a tag as-needed.
|
|
303
|
-
*/
|
|
304
|
-
tag(idFactory: (idFactory: this) => any): this;
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* **React Hook** - Subscribe to instance of controller within a component.
|
|
308
|
-
*
|
|
309
|
-
* This method will fire lifecycle events on given controller (as component).
|
|
310
|
-
*
|
|
311
|
-
* @param callback - Run once before subscription begins.
|
|
312
|
-
*/
|
|
313
|
-
use(callback?: (instance: this) => void): this;
|
|
314
|
-
|
|
315
|
-
/** Use symbol to access controller of a model. */
|
|
316
|
-
static CONTROL: typeof CONTROL;
|
|
317
|
-
|
|
318
|
-
/** Use symbol to access current state of a model. */
|
|
319
|
-
static STATE: typeof STATE;
|
|
320
|
-
|
|
321
|
-
/** Use symbol to access current subscriber of a model in a live context (e.g. hook or effect). */
|
|
322
|
-
static LOCAL: typeof LOCAL;
|
|
323
|
-
|
|
324
|
-
/** Use symbol to access keys affected by last update. */
|
|
325
|
-
static WHY: typeof WHY;
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Creates a new instance of this controller.
|
|
329
|
-
*
|
|
330
|
-
* Beyond `new this(...)`, method will activate managed-state.
|
|
331
|
-
*
|
|
332
|
-
* @param args - arguments sent to constructor
|
|
333
|
-
*/
|
|
334
|
-
static create <T extends Class> (this: T, ...args: ConstructorParameters<T>): InstanceOf<T>;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* **React Hook** - Spawn and maintain a controller from within a component.
|
|
338
|
-
*
|
|
339
|
-
* Differs from `use()` in lacking subscription and lifecycle events.
|
|
340
|
-
* Much more efficient if you don't need hook-based features.
|
|
341
|
-
*
|
|
342
|
-
* @param callback - Run after creation of instance.
|
|
343
|
-
*/
|
|
344
|
-
static new <T extends Class> (this: T, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* **React Hook** - Create and attach an instance of this controller a react component.
|
|
348
|
-
*
|
|
349
|
-
* Note: Model will be destroyed when ambient component unmounts!
|
|
350
|
-
*
|
|
351
|
-
* @param callback - Run after creation of instance.
|
|
352
|
-
*/
|
|
353
|
-
static use <T extends Class> (this: T, callback?: (instance: InstanceOf<T>) => void): InstanceOf<T>;
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* **React Hook** - Similar to `use`, will instanciate a controller bound to ambient component.
|
|
357
|
-
* Accepts an object of values which are injected into controller prior to activation.
|
|
358
|
-
*
|
|
359
|
-
* @param data - Data to be applied to controller upon creation.
|
|
360
|
-
*/
|
|
361
|
-
static uses <T extends Class, I extends InstanceOf<T>, D extends Partial<I>> (this: T, data: D, only?: (keyof D)[]): I;
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* **React Hook** - Similar to `uses`, will instanciate a controller includive of given data.
|
|
365
|
-
* This controller however will remain syncronized with input data at all times.
|
|
366
|
-
* Changes to input data between renders are captured and included in state/event stream.
|
|
367
|
-
*
|
|
368
|
-
* @param data - Data to be observed by controller.
|
|
369
|
-
*/
|
|
370
|
-
static using <T extends Class, I extends InstanceOf<T>, D extends Partial<I>> (this: T, data: D, only?: (keyof D)[]): I;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* **React Hook** - Fetch most instance of this controller from context, if it exists.
|
|
374
|
-
*
|
|
375
|
-
* @param required - If false, may return undefined.
|
|
376
|
-
*/
|
|
377
|
-
static get <T extends Class> (this: T, required?: true): InstanceOf<T>;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* **React Hook** - Fetch most instance of this controller from context.
|
|
381
|
-
*
|
|
382
|
-
* @param required - Unless false, will throw where instance cannot be found.
|
|
383
|
-
*/
|
|
384
|
-
static get <T extends Class> (this: T, required: boolean): InstanceOf<T> | undefined;
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* **React Hook** - Fetch specific value from instance of this controller in context.
|
|
388
|
-
*/
|
|
389
|
-
static get <T extends Class, I extends InstanceOf<T>, K extends Model.Fields<I>> (this: T, key: K): I[K];
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* **React Hook** - Fetch and subscribe to instance of this controller within ambient component.
|
|
393
|
-
*/
|
|
394
|
-
static tap <T extends Class> (this: T): InstanceOf<T>;
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* **React Hook** - Fetch and subscribe to a value on applicable instance within ambient component.
|
|
398
|
-
*/
|
|
399
|
-
static tap <T extends Class, I extends InstanceOf<T>, K extends Model.Fields<I>> (this: T, key: K, expect: true): Exclude<I[K], undefined>;
|
|
400
|
-
static tap <T extends Class, I extends InstanceOf<T>, K extends Model.Fields<I>> (this: T, key: K, expect?: boolean): I[K];
|
|
401
|
-
|
|
402
|
-
static tap <T, M extends Class, I extends InstanceOf<M>> (this: M, from: (this: I, state: I) => Promise<T>, expect: true): Exclude<T, undefined>;
|
|
403
|
-
static tap <T, M extends Class, I extends InstanceOf<M>> (this: M, from: (this: I, state: I) => Promise<T>, expect?: boolean): T | undefined;
|
|
404
|
-
|
|
405
|
-
static tap <T, M extends Class, I extends InstanceOf<M>> (this: M, from: (this: I, state: I) => T, expect: true): Exclude<T, undefined>;
|
|
406
|
-
static tap <T, M extends Class, I extends InstanceOf<M>> (this: M, from: (this: I, state: I) => T, expect?: boolean): T;
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* **React Hook** - Attach to instance of this controller within ambient component.
|
|
410
|
-
*
|
|
411
|
-
* This method will fire lifecycle events on given controller.
|
|
412
|
-
*
|
|
413
|
-
* @param id - Argument passed to controller-lifecycle methods. Use to identify the consumer.
|
|
414
|
-
*/
|
|
415
|
-
static tag <T extends Class, I extends InstanceOf<T>> (this: T, id?: Key): I;
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* **React Hook** - Attach to instance of this controller within ambient component.
|
|
419
|
-
*
|
|
420
|
-
* This method will fire lifecycle events on given controller.
|
|
421
|
-
*
|
|
422
|
-
* @param idFactory - Will be invoked with fetched instance. Use this to register a tag as-needed.
|
|
423
|
-
*/
|
|
424
|
-
static tag <T extends Class, I extends InstanceOf<T>> (this: T, idFactory: (on: I) => Key | void): I;
|
|
425
|
-
|
|
426
|
-
static meta <T extends Class>(this: T): T;
|
|
427
|
-
|
|
428
|
-
static meta <T extends Class, K extends keyof T> (this: T, key: K, expect: true): Exclude<T[K], undefined>;
|
|
429
|
-
static meta <T extends Class, K extends keyof T> (this: T, key: K, expect?: boolean): T[K];
|
|
430
|
-
|
|
431
|
-
static meta <T, M extends Class> (this: M, from: (this: M, state: M) => Promise<T>, expect: true): Exclude<T, undefined>;
|
|
432
|
-
static meta <T, M extends Class> (this: M, from: (this: M, state: M) => Promise<T>, expect?: boolean): T | undefined;
|
|
433
|
-
|
|
434
|
-
static meta <T, M extends Class> (this: M, from: (this: M, state: M) => T, expect: true): Exclude<T, undefined>;
|
|
435
|
-
static meta <T, M extends Class> (this: M, from: (this: M, state: M) => T, expect?: boolean): T;
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Static equivalent of `x instanceof this`.
|
|
439
|
-
*
|
|
440
|
-
* Will determine if provided class is a subtype of this one.
|
|
441
|
-
*/
|
|
442
|
-
static isTypeof <T extends Class>(this: T, subject: any): subject is T;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
export class Singleton extends Model {
|
|
446
|
-
/**
|
|
447
|
-
* Update the active instance of this class.
|
|
448
|
-
* Returns a thenable; resolves after successful update.
|
|
449
|
-
* If instance does not already exist, one will be created.
|
|
450
|
-
**/
|
|
451
|
-
static set<T extends Class>(
|
|
452
|
-
this: T, updates: Model.Compat<InstanceOf<T>>
|
|
453
|
-
): PromiseLike<string[] | false>;
|
|
454
|
-
|
|
455
|
-
/** Destroy current instance of Singleton, if it exists. */
|
|
456
|
-
static reset(): void;
|
|
457
|
-
}
|
package/types/types.d.ts
DELETED