@expressive/mvc 0.5.0 → 0.6.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 +42 -53
- package/lib/index.esm.js +266 -217
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +265 -217
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -229,9 +229,8 @@ declare function act<S>(action: Async<S>): typeof action & {
|
|
|
229
229
|
};
|
|
230
230
|
|
|
231
231
|
declare namespace get {
|
|
232
|
-
type Function<T,
|
|
233
|
-
type Factory<T,
|
|
234
|
-
type Getter = (controller: Controller, key: string) => any;
|
|
232
|
+
type Function<T, S = any> = (this: S, on: S) => T;
|
|
233
|
+
type Factory<T, S = unknown> = (this: S, key: string, thisArg: S) => T;
|
|
235
234
|
}
|
|
236
235
|
/**
|
|
237
236
|
* Implement a computed value; output will be generated by provided function.
|
|
@@ -248,35 +247,8 @@ declare function get<R, T>(source: T, compute: (this: T, on: T) => R, suspend?:
|
|
|
248
247
|
* @param compute - Factory function to generate a getter to subscribe dependancies.
|
|
249
248
|
* @param suspend - Value will throw suspense when evaulating to undefined.
|
|
250
249
|
*/
|
|
251
|
-
declare function get<R, T>(compute: (property: string) => (this: T, state: T) => R, suspend: true): Exclude<R, undefined>;
|
|
252
|
-
declare function get<R, T>(compute: (property: string) => (this: T, state: T) => R, suspend?: boolean): R;
|
|
253
|
-
|
|
254
|
-
declare namespace ref {
|
|
255
|
-
type Callback<T, S = any> = (this: S, argument: T) => ((next: T) => void) | Promise<void> | void | boolean;
|
|
256
|
-
interface Object<T = any> {
|
|
257
|
-
(next: T): void;
|
|
258
|
-
current: T | null;
|
|
259
|
-
}
|
|
260
|
-
/** Object with references to all managed values of `T`. */
|
|
261
|
-
type Proxy<T extends Model> = {
|
|
262
|
-
[P in Model.Field<T>]: Model.Ref<T[P]>;
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Creates a ref-compatible property.
|
|
267
|
-
* Will persist value, and updates to this are made part of controller event-stream.
|
|
268
|
-
*
|
|
269
|
-
* *Output is simultaneously a ref-function and ref-object, use as needed.*
|
|
270
|
-
*
|
|
271
|
-
* @param callback - Optional callback to synchronously fire when reference is first set or does update.
|
|
272
|
-
*/
|
|
273
|
-
declare function ref<T = HTMLElement>(callback?: ref.Callback<T>): ref.Object<T>;
|
|
274
|
-
declare function ref<T, S>(callback?: ref.Callback<T, S>): ref.Object<T>;
|
|
275
|
-
|
|
276
|
-
declare namespace set$1 {
|
|
277
|
-
type Factory<T, S = unknown> = (this: S, key: string, subject: S) => T;
|
|
278
|
-
type Callback<T, S = any> = (this: S, argument: T) => ((next: T) => void) | Promise<any> | void | boolean;
|
|
279
|
-
}
|
|
250
|
+
declare function get<R, T>(compute: (property: string, on: T) => (this: T, state: T) => R, suspend: true): Exclude<R, undefined>;
|
|
251
|
+
declare function get<R, T>(compute: (property: string, on: T) => (this: T, state: T) => R, suspend?: boolean): R;
|
|
280
252
|
/**
|
|
281
253
|
* Set property with an async function.
|
|
282
254
|
*
|
|
@@ -292,12 +264,10 @@ declare namespace set$1 {
|
|
|
292
264
|
* @param factory - Callback run to derrive property value.
|
|
293
265
|
* @param required - (default: true) Run factory immediately on creation, otherwise on access.
|
|
294
266
|
*/
|
|
295
|
-
declare function
|
|
296
|
-
declare function
|
|
297
|
-
declare function
|
|
298
|
-
declare function
|
|
299
|
-
declare function put<T>(value: set$1.Factory<Promise<T>>, onUpdate: set$1.Callback<T>): T;
|
|
300
|
-
declare function put<T, S>(value: set$1.Factory<Promise<T>, S>, onUpdate: set$1.Callback<T, S>): T;
|
|
267
|
+
declare function get<T>(factory: get.Factory<Promise<T>>, required: false): T | undefined;
|
|
268
|
+
declare function get<T, S>(factory: get.Factory<Promise<T>, S>, required: false): T | undefined;
|
|
269
|
+
declare function get<T>(factory: get.Factory<Promise<T>>, required?: boolean): T;
|
|
270
|
+
declare function get<T, S>(factory: get.Factory<Promise<T>, S>, required?: boolean): T;
|
|
301
271
|
/**
|
|
302
272
|
* Set property with a factory function.
|
|
303
273
|
*
|
|
@@ -310,24 +280,37 @@ declare function put<T, S>(value: set$1.Factory<Promise<T>, S>, onUpdate: set$1.
|
|
|
310
280
|
* @param factory - Callback run to derrive property value.
|
|
311
281
|
* @param required - (default: true) Run factory immediately on creation, otherwise on access.
|
|
312
282
|
*/
|
|
313
|
-
declare function
|
|
314
|
-
declare function
|
|
315
|
-
declare function
|
|
316
|
-
declare function
|
|
317
|
-
declare function put<T>(value: set$1.Factory<T>, onUpdate: set$1.Callback<T>): T;
|
|
318
|
-
declare function put<T, S>(value: set$1.Factory<T, S>, onUpdate: set$1.Callback<T, S>): T;
|
|
283
|
+
declare function get<T>(factory: get.Factory<T>, required: false): T | undefined;
|
|
284
|
+
declare function get<T, S>(factory: get.Factory<T, S>, required: false): T | undefined;
|
|
285
|
+
declare function get<T>(factory: get.Factory<T>, required?: boolean): T;
|
|
286
|
+
declare function get<T, S>(factory: get.Factory<T, S>, required?: boolean): T;
|
|
319
287
|
/**
|
|
320
288
|
* Assign a property with result of a promise.
|
|
321
289
|
*/
|
|
322
|
-
declare function
|
|
323
|
-
declare function
|
|
324
|
-
|
|
290
|
+
declare function get<T>(factory: Promise<T>, required: false): T | undefined;
|
|
291
|
+
declare function get<T>(factory: Promise<T>, required?: boolean): T;
|
|
292
|
+
|
|
293
|
+
declare namespace ref {
|
|
294
|
+
type Callback<T, S = any> = (this: S, argument: T) => ((next: T) => void) | Promise<void> | void | boolean;
|
|
295
|
+
interface Object<T = any> {
|
|
296
|
+
(next: T): void;
|
|
297
|
+
current: T | null;
|
|
298
|
+
}
|
|
299
|
+
/** Object with references to all managed values of `T`. */
|
|
300
|
+
type Proxy<T extends Model> = {
|
|
301
|
+
[P in Model.Field<T>]: Model.Ref<T[P]>;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
325
304
|
/**
|
|
326
|
-
*
|
|
305
|
+
* Creates a ref-compatible property.
|
|
306
|
+
* Will persist value, and updates to this are made part of controller event-stream.
|
|
307
|
+
*
|
|
308
|
+
* *Output is simultaneously a ref-function and ref-object, use as needed.*
|
|
309
|
+
*
|
|
310
|
+
* @param callback - Optional callback to synchronously fire when reference is first set or does update.
|
|
327
311
|
*/
|
|
328
|
-
declare function
|
|
329
|
-
declare function
|
|
330
|
-
declare function put<T>(value: T, onUpdate: set$1.Callback<T>): T;
|
|
312
|
+
declare function ref<T = HTMLElement>(callback?: ref.Callback<T>): ref.Object<T>;
|
|
313
|
+
declare function ref<T, S>(callback?: ref.Callback<T, S>): ref.Object<T>;
|
|
331
314
|
|
|
332
315
|
declare namespace set {
|
|
333
316
|
type Callback<T, S = any> = (this: S, argument: T) => ((next: T) => void) | Promise<any> | void | boolean;
|
|
@@ -347,10 +330,11 @@ declare function set<T>(value: T, onUpdate: set.Callback<T>): T;
|
|
|
347
330
|
declare function set<T, S>(value: T, onUpdate: set.Callback<T, S>): T;
|
|
348
331
|
|
|
349
332
|
declare 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;
|
|
350
|
-
declare type Managed<T> = T & {
|
|
333
|
+
declare type Managed<T> = Exclude<T, "forEach"> & {
|
|
351
334
|
from?: T;
|
|
352
335
|
forEach<R>(mapFunction: MapFunction<T, R>, thisArg?: any): Exclude<R, undefined>[] | void;
|
|
353
336
|
};
|
|
337
|
+
|
|
354
338
|
declare function use<K = any>(initial: SetConstructor): Managed<Set<K>>;
|
|
355
339
|
declare function use<K = any, V = any>(initial: MapConstructor): Managed<Map<K, V>>;
|
|
356
340
|
declare function use(initial: Set<unknown>): Managed<Set<any>>;
|
|
@@ -363,6 +347,8 @@ declare function use<T extends Set<any> | Map<any, any>>(from: () => T): Managed
|
|
|
363
347
|
* Create a placeholder for specified Model type.
|
|
364
348
|
*/
|
|
365
349
|
declare function use<T extends Model>(): T | undefined;
|
|
350
|
+
declare function use<T extends Model>(from: () => T, required: false): T | undefined;
|
|
351
|
+
declare function use<T extends Model>(from: () => T, required: boolean): T;
|
|
366
352
|
/**
|
|
367
353
|
* Create a new child instance of model.
|
|
368
354
|
*/
|
|
@@ -370,6 +356,9 @@ declare function use<T extends Class>(Type: T, callback?: (i: InstanceOf<T>) =>
|
|
|
370
356
|
/**
|
|
371
357
|
* Create a managed child from factory function.
|
|
372
358
|
*/
|
|
359
|
+
declare function use<T extends {}>(from: () => Promise<T>, required: false): T | undefined;
|
|
360
|
+
declare function use<T extends {}>(from: () => Promise<T>, required: boolean): T;
|
|
361
|
+
declare function use<T extends {}>(from: () => Promise<T>, callback?: (i: T) => void): T;
|
|
373
362
|
declare function use<T extends {}>(from: () => T, callback?: (i: T) => void): T;
|
|
374
363
|
/**
|
|
375
364
|
* Create child-instance relationship with provided model.
|
|
@@ -625,4 +614,4 @@ declare function useTap<T extends Stateful, K extends Model.Field<T>>(source: T
|
|
|
625
614
|
declare function useTap<T extends Stateful, R>(source: T | (() => T) | useTap.Tappable, compute: (this: T, from: T) => R, expect: true): Exclude<R, undefined>;
|
|
626
615
|
declare function useTap<T extends Stateful, R>(source: T | (() => T) | useTap.Tappable, compute: (this: T, from: T) => R, expect?: boolean): R;
|
|
627
616
|
|
|
628
|
-
export { CONTROL, Consumer, Global, LOCAL, MVC as Model, Provider, STATE, Stateful, WHY, act, apply, MVC as default, get, has,
|
|
617
|
+
export { CONTROL, Consumer, Global, LOCAL, MVC as Model, Provider, STATE, Stateful, WHY, act, apply, MVC as default, get, has, ref, set, tap, use, useFrom, useLocal, useModel, useTap };
|