piral-core 1.6.2-beta.7421 → 1.6.2-beta.7472

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.
@@ -6,13 +6,17 @@ import { none } from '../utils';
6
6
  * The Mediator component for interfacing with pilets loading.
7
7
  */
8
8
  export const Mediator = ({ options }) => {
9
- const { initialize, readState } = useGlobalStateContext();
9
+ const { initialize, readState, emit } = useGlobalStateContext();
10
10
  React.useEffect(() => {
11
- const shouldLoad = readState(s => s.app.loading);
11
+ const shouldLoad = readState((s) => s.app.loading);
12
12
  if (shouldLoad) {
13
13
  const { connect, disconnect } = startLoadingPilets(options);
14
+ emit('loading-pilets', { options });
14
15
  const notifier = (error, pilets, loaded) => {
15
16
  initialize(!loaded, error, pilets);
17
+ if (loaded) {
18
+ emit('loaded-pilets', { pilets, error });
19
+ }
16
20
  };
17
21
  connect(notifier);
18
22
  return () => disconnect(notifier);
@@ -1 +1 @@
1
- {"version":3,"file":"Mediator.js","sourceRoot":"","sources":["../../src/components/Mediator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAqB,kBAAkB,EAAiB,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAYhC;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA4B,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IAC/D,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,qBAAqB,EAAE,CAAC;IAE1D,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEjD,IAAI,UAAU,EAAE;YACd,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE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gBACxD,UAAU,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBAEnC,IAAI,MAAM,EAAE;oBACV,IAAI,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;iBAC1C;YACH,CAAC,CAAC;YACF,OAAO,CAAC,QAAQ,CAAC,CAAC;YAClB,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;SACnC;IACH,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,2CAA2C;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { Pilet, LoadPiletsOptions } from 'piral-base';
1
2
  import type { PiralCustomEventMap } from './custom';
2
3
  /**
3
4
  * A key value store that can be abstracted onto a storage solution (e.g. cookie).
@@ -76,9 +77,33 @@ export interface PiralUnhandledErrorEvent {
76
77
  */
77
78
  pilet: string;
78
79
  }
80
+ /**
81
+ * Gets fired when all pilets have been loaded.
82
+ */
83
+ export interface PiralLoadedPiletsEvent {
84
+ /**
85
+ * The pilets that have been loaded.
86
+ */
87
+ pilets: Array<Pilet>;
88
+ /**
89
+ * The loading error, if any.
90
+ */
91
+ error?: Error;
92
+ }
93
+ /**
94
+ * Gets fired when the loading of pilets is triggered.
95
+ */
96
+ export interface PiralLoadingPiletsEvent {
97
+ /**
98
+ * The options that have been supplied for loading the pilets.
99
+ */
100
+ options: LoadPiletsOptions;
101
+ }
79
102
  declare module 'piral-base/lib/types/api' {
80
103
  interface PiralEventMap extends PiralCustomEventMap {
81
104
  'store-data': PiralStoreDataEvent;
82
105
  'unhandled-error': PiralUnhandledErrorEvent;
106
+ 'loading-pilets': PiralLoadingPiletsEvent;
107
+ 'loaded-pilets': PiralLoadedPiletsEvent;
83
108
  }
84
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-core",
3
- "version": "1.6.2-beta.7421",
3
+ "version": "1.6.2-beta.7472",
4
4
  "description": "The core library for creating a Piral instance.",
5
5
  "keywords": [
6
6
  "portal",
@@ -61,8 +61,8 @@
61
61
  "test": "echo \"Error: run tests from root\" && exit 1"
62
62
  },
63
63
  "dependencies": {
64
- "piral-base": "1.6.2-beta.7421",
65
- "piral-debug-utils": "1.6.2-beta.7421",
64
+ "piral-base": "1.6.2-beta.7472",
65
+ "piral-debug-utils": "1.6.2-beta.7472",
66
66
  "zustand": "^3.0.0"
67
67
  },
68
68
  "devDependencies": {
@@ -82,5 +82,5 @@
82
82
  "react-router-dom",
83
83
  "tslib"
84
84
  ],
85
- "gitHead": "a225faea9c8d36d92ac81066ebb40db97a65fd34"
85
+ "gitHead": "3dd0674c8a6af8b5e1ab66fed6813ee7565f0ed9"
86
86
  }
@@ -17,20 +17,26 @@ export interface MediatorProps {
17
17
  * The Mediator component for interfacing with pilets loading.
18
18
  */
19
19
  export const Mediator: React.FC<MediatorProps> = ({ options }) => {
20
- const { initialize, readState } = useGlobalStateContext();
20
+ const { initialize, readState, emit } = useGlobalStateContext();
21
21
 
22
22
  React.useEffect(() => {
23
- const shouldLoad = readState(s => s.app.loading);
23
+ const shouldLoad = readState((s) => s.app.loading);
24
24
 
25
25
  if (shouldLoad) {
26
26
  const { connect, disconnect } = startLoadingPilets(options);
27
+
28
+ emit('loading-pilets', { options });
29
+
27
30
  const notifier: PiletsLoading = (error, pilets, loaded) => {
28
31
  initialize(!loaded, error, pilets);
32
+
33
+ if (loaded) {
34
+ emit('loaded-pilets', { pilets, error });
35
+ }
29
36
  };
30
37
  connect(notifier);
31
38
  return () => disconnect(notifier);
32
39
  }
33
-
34
40
  }, none);
35
41
 
36
42
  // tslint:disable-next-line:no-null-keyword
@@ -1,4 +1,4 @@
1
- import type {} from 'piral-base';
1
+ import type { Pilet, LoadPiletsOptions } from 'piral-base';
2
2
  import type { PiralCustomEventMap } from './custom';
3
3
 
4
4
  /**
@@ -82,9 +82,35 @@ export interface PiralUnhandledErrorEvent {
82
82
  pilet: string;
83
83
  }
84
84
 
85
+ /**
86
+ * Gets fired when all pilets have been loaded.
87
+ */
88
+ export interface PiralLoadedPiletsEvent {
89
+ /**
90
+ * The pilets that have been loaded.
91
+ */
92
+ pilets: Array<Pilet>;
93
+ /**
94
+ * The loading error, if any.
95
+ */
96
+ error?: Error;
97
+ }
98
+
99
+ /**
100
+ * Gets fired when the loading of pilets is triggered.
101
+ */
102
+ export interface PiralLoadingPiletsEvent {
103
+ /**
104
+ * The options that have been supplied for loading the pilets.
105
+ */
106
+ options: LoadPiletsOptions;
107
+ }
108
+
85
109
  declare module 'piral-base/lib/types/api' {
86
110
  interface PiralEventMap extends PiralCustomEventMap {
87
111
  'store-data': PiralStoreDataEvent;
88
112
  'unhandled-error': PiralUnhandledErrorEvent;
113
+ 'loading-pilets': PiralLoadingPiletsEvent;
114
+ 'loaded-pilets': PiralLoadedPiletsEvent;
89
115
  }
90
116
  }