@mulsense/xnew 0.3.0 → 0.3.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.
@@ -26,7 +26,7 @@ interface UnitInternal {
26
26
  protected: boolean;
27
27
  ancestors: Unit[];
28
28
  children: Unit[];
29
- promises: Promise<any>[];
29
+ promises: UnitPromise[];
30
30
  elements: UnitElement[];
31
31
  components: Function[];
32
32
  listeners: MapMap<string, Function, {
@@ -41,7 +41,6 @@ export declare class Unit {
41
41
  _: UnitInternal;
42
42
  constructor(parent: Unit | null, ...args: any[]);
43
43
  get element(): UnitElement;
44
- get components(): Function[];
45
44
  start(): void;
46
45
  stop(): void;
47
46
  finalize(): void;
@@ -71,7 +70,7 @@ export declare class Unit {
71
70
  static emit(type: string, ...args: any[]): void;
72
71
  }
73
72
  export declare class UnitPromise {
74
- private promise;
73
+ promise: Promise<any>;
75
74
  constructor(promise: Promise<any>);
76
75
  then(callback: Function): UnitPromise;
77
76
  catch(callback: Function): UnitPromise;
package/dist/xnew.d.ts CHANGED
@@ -52,7 +52,7 @@ interface UnitInternal {
52
52
  protected: boolean;
53
53
  ancestors: Unit[];
54
54
  children: Unit[];
55
- promises: Promise<any>[];
55
+ promises: UnitPromise[];
56
56
  elements: UnitElement[];
57
57
  components: Function[];
58
58
  listeners: MapMap<string, Function, {
@@ -67,7 +67,6 @@ declare class Unit {
67
67
  _: UnitInternal;
68
68
  constructor(parent: Unit | null, ...args: any[]);
69
69
  get element(): UnitElement;
70
- get components(): Function[];
71
70
  start(): void;
72
71
  stop(): void;
73
72
  finalize(): void;
@@ -97,7 +96,7 @@ declare class Unit {
97
96
  static emit(type: string, ...args: any[]): void;
98
97
  }
99
98
  declare class UnitPromise {
100
- private promise;
99
+ promise: Promise<any>;
101
100
  constructor(promise: Promise<any>);
102
101
  then(callback: Function): UnitPromise;
103
102
  catch(callback: Function): UnitPromise;
package/dist/xnew.js CHANGED
@@ -262,9 +262,6 @@
262
262
  get element() {
263
263
  return this._.currentElement;
264
264
  }
265
- get components() {
266
- return this._.components;
267
- }
268
265
  start() {
269
266
  this._.tostart = true;
270
267
  }
@@ -313,7 +310,7 @@
313
310
  // setup component
314
311
  Unit.extend(unit, unit._.baseComponent, unit._.props);
315
312
  // whether the unit promise was resolved
316
- Promise.all(unit._.promises).then(() => unit._.state = 'initialized');
313
+ Promise.all(unit._.promises.map(p => p.promise)).then(() => unit._.state = 'initialized');
317
314
  Unit.current = backup;
318
315
  }
319
316
  static finalize(unit) {
@@ -680,8 +677,8 @@
680
677
  */
681
678
  promise(promise) {
682
679
  try {
683
- Unit.current._.promises.push(promise);
684
- return new UnitPromise(promise);
680
+ Unit.current._.promises.push(new UnitPromise(promise));
681
+ return Unit.current._.promises[Unit.current._.promises.length - 1];
685
682
  }
686
683
  catch (error) {
687
684
  console.error('xnew.promise(promise: Promise<any>): ', error);
@@ -697,7 +694,7 @@
697
694
  */
698
695
  then(callback) {
699
696
  try {
700
- return new UnitPromise(Promise.all(Unit.current._.promises)).then(callback);
697
+ return new UnitPromise(Promise.all(Unit.current._.promises.map(p => p.promise))).then(callback);
701
698
  }
702
699
  catch (error) {
703
700
  console.error('xnew.then(callback: Function): ', error);
@@ -713,7 +710,7 @@
713
710
  */
714
711
  catch(callback) {
715
712
  try {
716
- return new UnitPromise(Promise.all(Unit.current._.promises)).catch(callback);
713
+ return new UnitPromise(Promise.all(Unit.current._.promises.map(p => p.promise))).catch(callback);
717
714
  }
718
715
  catch (error) {
719
716
  console.error('xnew.catch(callback: Function): ', error);
@@ -729,7 +726,7 @@
729
726
  */
730
727
  finally(callback) {
731
728
  try {
732
- return new UnitPromise(Promise.all(Unit.current._.promises)).finally(callback);
729
+ return new UnitPromise(Promise.all(Unit.current._.promises.map(p => p.promise))).finally(callback);
733
730
  }
734
731
  catch (error) {
735
732
  console.error('xnew.finally(callback: Function): ', error);
package/dist/xnew.mjs CHANGED
@@ -256,9 +256,6 @@ class Unit {
256
256
  get element() {
257
257
  return this._.currentElement;
258
258
  }
259
- get components() {
260
- return this._.components;
261
- }
262
259
  start() {
263
260
  this._.tostart = true;
264
261
  }
@@ -307,7 +304,7 @@ class Unit {
307
304
  // setup component
308
305
  Unit.extend(unit, unit._.baseComponent, unit._.props);
309
306
  // whether the unit promise was resolved
310
- Promise.all(unit._.promises).then(() => unit._.state = 'initialized');
307
+ Promise.all(unit._.promises.map(p => p.promise)).then(() => unit._.state = 'initialized');
311
308
  Unit.current = backup;
312
309
  }
313
310
  static finalize(unit) {
@@ -674,8 +671,8 @@ const xnew$1 = Object.assign(function (...args) {
674
671
  */
675
672
  promise(promise) {
676
673
  try {
677
- Unit.current._.promises.push(promise);
678
- return new UnitPromise(promise);
674
+ Unit.current._.promises.push(new UnitPromise(promise));
675
+ return Unit.current._.promises[Unit.current._.promises.length - 1];
679
676
  }
680
677
  catch (error) {
681
678
  console.error('xnew.promise(promise: Promise<any>): ', error);
@@ -691,7 +688,7 @@ const xnew$1 = Object.assign(function (...args) {
691
688
  */
692
689
  then(callback) {
693
690
  try {
694
- return new UnitPromise(Promise.all(Unit.current._.promises)).then(callback);
691
+ return new UnitPromise(Promise.all(Unit.current._.promises.map(p => p.promise))).then(callback);
695
692
  }
696
693
  catch (error) {
697
694
  console.error('xnew.then(callback: Function): ', error);
@@ -707,7 +704,7 @@ const xnew$1 = Object.assign(function (...args) {
707
704
  */
708
705
  catch(callback) {
709
706
  try {
710
- return new UnitPromise(Promise.all(Unit.current._.promises)).catch(callback);
707
+ return new UnitPromise(Promise.all(Unit.current._.promises.map(p => p.promise))).catch(callback);
711
708
  }
712
709
  catch (error) {
713
710
  console.error('xnew.catch(callback: Function): ', error);
@@ -723,7 +720,7 @@ const xnew$1 = Object.assign(function (...args) {
723
720
  */
724
721
  finally(callback) {
725
722
  try {
726
- return new UnitPromise(Promise.all(Unit.current._.promises)).finally(callback);
723
+ return new UnitPromise(Promise.all(Unit.current._.promises.map(p => p.promise))).finally(callback);
727
724
  }
728
725
  catch (error) {
729
726
  console.error('xnew.finally(callback: Function): ', error);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "Component-Oriented Programming"
6
6
  ],
7
- "version": "0.3.0",
7
+ "version": "0.3.1",
8
8
  "main": "dist/xnew.js",
9
9
  "module": "dist/xnew.mjs",
10
10
  "types": "dist/xnew.d.ts",