@expressive/mvc 0.3.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +18 -35
- package/lib/index.esm.js +670 -491
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +670 -491
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -31,12 +31,12 @@ declare type Listener = {
|
|
|
31
31
|
declare class Subscriber<T extends Stateful = any> {
|
|
32
32
|
onUpdate: Controller.OnEvent;
|
|
33
33
|
proxy: T;
|
|
34
|
+
commit: () => Callback;
|
|
34
35
|
release: Callback;
|
|
35
|
-
commit: () => () => void;
|
|
36
36
|
active: boolean;
|
|
37
37
|
dependant: Set<Listener>;
|
|
38
|
-
|
|
39
|
-
constructor(
|
|
38
|
+
add: (key: any, value?: Callback) => void;
|
|
39
|
+
constructor(parent: Controller<T>, onUpdate: Controller.OnEvent);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
declare const CONTROL: unique symbol;
|
|
@@ -49,7 +49,7 @@ interface Stateful {
|
|
|
49
49
|
/** Current subscriber (if present) while used in a live context (e.g. hook or effect). */
|
|
50
50
|
[LOCAL]?: Subscriber;
|
|
51
51
|
/** Current state of this instance. */
|
|
52
|
-
[STATE]?: this
|
|
52
|
+
[STATE]?: Model.Values<this>;
|
|
53
53
|
/**
|
|
54
54
|
* Last update causing a refresh to subscribers.
|
|
55
55
|
*
|
|
@@ -133,7 +133,7 @@ declare class Model {
|
|
|
133
133
|
static [CONTROL]: Controller;
|
|
134
134
|
static [WHY]: readonly string[];
|
|
135
135
|
constructor();
|
|
136
|
-
get [STATE](): this
|
|
136
|
+
get [STATE](): Model.Values<this, Exclude<keyof this & string, keyof Model>>;
|
|
137
137
|
get [WHY](): readonly string[] | undefined;
|
|
138
138
|
on<P = Model.Event<this>>(event: (key: P) => Callback | void): Callback;
|
|
139
139
|
on<P = Model.Event<this>>(keys: [], listener: Model.OnUpdate<this, P>, squash?: boolean, once?: boolean): Callback;
|
|
@@ -149,7 +149,7 @@ declare class Model {
|
|
|
149
149
|
once<P extends Model.Event<this>>(key: P | P[], listener: Model.OnUpdate<this, P>, squash?: false): Callback;
|
|
150
150
|
once<P extends Model.Event<this>>(key: P | P[], listener: (keys: P[]) => void, squash: true): Callback;
|
|
151
151
|
once<P extends Model.Event<this>>(key: P | P[], listener: unknown, squash: boolean): Callback;
|
|
152
|
-
once<P extends Model.Event<this>>(key: P | P[]): Promise<
|
|
152
|
+
once<P extends Model.Event<this>>(key: P | P[], timeout?: number): Promise<void>;
|
|
153
153
|
effect(callback: Model.Effect<this>): Callback;
|
|
154
154
|
effect(callback: Model.Effect<this>, select: []): Callback;
|
|
155
155
|
effect(callback: Model.Effect<this>, select: Model.Event<this>[]): Callback;
|
|
@@ -185,30 +185,22 @@ declare class Model {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
declare namespace Controller {
|
|
188
|
-
type OnValue<T = any
|
|
189
|
-
type OnEvent<T = any> = (key: Model.Event<T
|
|
188
|
+
type OnValue<T = any> = (this: T, value: any) => boolean | void;
|
|
189
|
+
type OnEvent<T = any> = (key: Model.Event<T> | null, source: Controller) => Callback | void;
|
|
190
190
|
}
|
|
191
191
|
declare class Controller<T extends Stateful = any> {
|
|
192
192
|
subject: T;
|
|
193
|
-
|
|
194
|
-
state: Model.Values<T, Exclude<keyof T & string, keyof Model>>;
|
|
193
|
+
state: Map<any, any>;
|
|
195
194
|
frame: Set<string>;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
protected followers: Set<Model.Controller.OnEvent<any>>;
|
|
195
|
+
waiting: Set<Callback>;
|
|
196
|
+
followers: Set<Model.Controller.OnEvent<any>>;
|
|
199
197
|
constructor(subject: T);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
manage(key: Model.Field<T>, value: any): void;
|
|
203
|
-
ref(key: Model.Field<T>, handler?: Controller.OnValue<T>): (value: any) => void;
|
|
198
|
+
subscribe(callback: Controller.OnEvent<T>): Model.Subscriber<T>;
|
|
199
|
+
add(key: keyof T & string): void;
|
|
204
200
|
addListener(listener: Controller.OnEvent<T>): () => void;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
requestUpdate(strict: true): Promise<readonly Model.Event<T>[]>;
|
|
209
|
-
requestUpdate(strict: false): Promise<false>;
|
|
210
|
-
requestUpdate(strict: boolean): Promise<readonly Model.Event<T>[] | false>;
|
|
211
|
-
requestUpdate(callback: Callback): void;
|
|
201
|
+
ref(key: Model.Field<T>, handler?: Controller.OnValue<T>): (value: any) => void;
|
|
202
|
+
update(key: Model.Field<T>): void;
|
|
203
|
+
clear(): void;
|
|
212
204
|
}
|
|
213
205
|
|
|
214
206
|
/**
|
|
@@ -217,8 +209,8 @@ declare class Controller<T extends Stateful = any> {
|
|
|
217
209
|
*/
|
|
218
210
|
declare type Instruction<T> = (this: Controller, key: string, thisArg: Controller) => Instruction.Getter<T> | Instruction.ExplicitDescriptor | Instruction.Descriptor<T> | Instruction.RecursiveDescriptor<T> | boolean | void;
|
|
219
211
|
declare namespace Instruction {
|
|
220
|
-
type Getter<T> = (
|
|
221
|
-
type Setter<T> = (value: T
|
|
212
|
+
type Getter<T> = (within?: Subscriber) => T;
|
|
213
|
+
type Setter<T> = (value: T) => boolean | void;
|
|
222
214
|
type Runner<T> = (this: Controller, key: string, on: Controller) => Instruction.Descriptor<T> | boolean | undefined;
|
|
223
215
|
interface Descriptor<T> {
|
|
224
216
|
configurable?: boolean;
|
|
@@ -280,15 +272,6 @@ declare namespace ref {
|
|
|
280
272
|
[P in Model.Field<T>]: Model.Ref<T[P]>;
|
|
281
273
|
};
|
|
282
274
|
}
|
|
283
|
-
/**
|
|
284
|
-
* Creates an object with references to all managed values.
|
|
285
|
-
* Each property will set value in state when invoked.
|
|
286
|
-
*
|
|
287
|
-
* *Properties are simultaneously a ref-function and ref-object, use as needed.*
|
|
288
|
-
*
|
|
289
|
-
* @param target - Source model from which to reference values.
|
|
290
|
-
*/
|
|
291
|
-
declare function ref<T extends Model>(target: T): ref.Proxy<T>;
|
|
292
275
|
/**
|
|
293
276
|
* Creates a ref-compatible property.
|
|
294
277
|
* Will persist value, and updates to this are made part of controller event-stream.
|