/
ParcelObject.ts
60 lines (55 loc) · 2.11 KB
/
ParcelObject.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { CustomProps } from './CustomProps';
/**
* Parcel object, similar to `React.Element` with the only difference that it is mutable.
* While {@link ParcelConfig} is a `React.Component`.
*/
export interface ParcelObject<ExtraProps = CustomProps> {
/**
* Returns a promise that resolves once the parcel is successfully mounted. The promise can throw an error which needs to be handled.
*/
mount(): Promise<null>;
/**
* Returns a promise that resolves once the parcel is successfully unmounted. The promise may throw an error which needs to be handled.
*/
unmount(): Promise<null>;
/**
* Allows you to change the props passed into a parcel. Note that not all parcels support being updated.
* The update function returns a promise that resolves when the parcel is finished updating.
* See [other documentation](https://single-spa.js.org/docs/parcels-overview.html#update-optional)
* and [example](https://single-spa.js.org/docs/parcels-overview.html#quick-example) for more information.
* @param customProps
*/
update?(customProps: ExtraProps): Promise<null>;
/**
* Returns a string of that parcels status. The string status is one of the following:
*/
getStatus():
| 'NOT_LOADED'
| 'LOADING_SOURCE_CODE'
| 'NOT_BOOTSTRAPPED'
| 'BOOTSTRAPPING'
| 'NOT_MOUNTED'
| 'MOUNTING'
| 'MOUNTED'
| 'UPDATING'
| 'UNMOUNTING'
| 'UNLOADING'
| 'SKIP_BECAUSE_BROKEN'
| 'LOAD_ERROR';
/**
* Returns a promise that will resolve once the parcel has been loaded.
*/
loadPromise: Promise<null>;
/**
* Returns a promise that will resolve once the parcel has been bootstrapped.
*/
bootstrapPromise: Promise<null>;
/**
* Returns a promise that will resolve once the parcel has been mounted. This is helpful for knowing exactly when a parcel has been appended to the DOM
*/
mountPromise: Promise<null>;
/**
* Returns a promise that will resolve once the parcel has been unmounted.
*/
unmountPromise: Promise<null>;
}