Parcels API
Most parcel methods will be called on the parcel itself, with the exception being around mounting.
#
mountingBoth mount methods take a parcelConfig and additional props. They both return a parcel object. The parcel object contains all additional exposed methods.
#
Parcel PropsWhen mounting a parcel the second argument is props, a JavaScript object of properties to be passed to the parcel. This object must have a domElement prop, which is the dom node that the parcel will mount into.
#
mountParcelapplicationProps.mountParcel(parcelConfig, parcelProps)
. Each application is provided a mountParcel function.
The main advantage to using an applications mountParcel
function is that parcels mounted via an
applications mountParcel
will be automatically unmounted when the application is unmounted.
The first argument may be either an object or a function that returns a promise that resolves with the object (a loading function).
#
mountRootParcelThe mountRootParcel method will mount the parcel but unmount
must be called manually.
#
Parcel ObjectThe parcel object contains the following functions and methods:
#
unmountparcel.unmount()
returns a promise that resolves once the parcel is successfully unmounted. The promise may throw an error which needs to be handled.
#
mountparcel.mount()
returns a promise that resolves once the parcel is successfully mounted. The promise can throw an error which needs to be handled.
#
updateparcel.update(props)
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 and example for more information.
#
getStatusparcel.getStatus()
retuns a string of that parcels status. The string status is one of the following:
NOT_BOOTSTRAPPED
: The parcel has not been bootstrappedBOOTSTRAPPING
: The parcel is bootstrapping but has not finishedNOT_MOUNTED
: The parcel has bootstrapped, but is not mountedMOUNTED
: The parcel is currently active and mounted to the DOMUNMOUNTING
: The parcel is unmounting, but has not finishedUPDATING
: The parcel is currently being updated, but has not finishedSKIP_BECAUSE_BROKEN
: The parcel threw an error during bootstrap, mount, unmount, or update. Other parcels may continue normally, but this one will be skipped.
#
loadPromiseparcel.loadPromise()
returns a promise that will resolve once the parcel has been loaded.
#
bootstrapPromiseparcel.bootstrapPromise()
returns a promise that will resolve once the parcel has been bootstrapped.
#
mountPromiseparcel.mountPromise()
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
#
unmountPromiseparcel.unmountPromise()
returns a promise that will resolve once the parcel has been unmounted.