The base class for all environment types
The environment object is available via the globally declared coenv
variable.
Never modify, nor cache the environment object as it can (and will) change from request to request in a server environment.
class Environment extends EventTarget {
browser: boolean;
ssr: boolean;
enterLoading(): void;
leaveLoading(): void;
get loading(): boolean;
load(callback: () => Promise<any>): Promise<any>;
untilLoaded(): Promise<void>;
}
True when running in browser environment.
browser: boolean;
Notifies the environment that an async load operation is starting.
Environment level loading notifications are used when rendering to determine when the initial page load has completed and rendering can commence.
enterLoading(): void;
Notifies the environment that an async load operation has finished.
leaveLoading(): void;
Runs an async data load operation.
load(callback: () => Promise<any>): Promise<any>;
callback
A callback that performs the data loadReturns true
if there are in progress async load operations.
get loading(): boolean;
True when running in a rendering environment.
ssr: boolean;
Returns a promise that resolves when any pending load operations have finished.
untilLoaded(): Promise<void>;
Sets an environment provider.
function setEnvProvider(value: () => Environment): void;
value
A callback to provide the current environment object