@fluidframework/base-host
TypeScript icon, indicating that this package has built-in type declarations

0.50.1 • Public • Published

@fluidframework/base-host

BaseHost provides an easy-to-use entry point for hosts of Fluid experiences. Given a configuration, it helps load and initialize a container and provides helpers to retrieve Fluid objects from that container.

BaseHost

Creation

To create a BaseHost, you'll need to profide a configuration IBaseHostConfig.

const baseHostConfig = {
    codeResolver, // an IFluidCodeResolver
    documentServiceFactory, // an IDocumentServiceFactory
    urlResolver, // an IUrlResolver
};
const baseHost = new BaseHost(baseHostConfig);

IBaseHostConfig

The key members of IBaseHostConfig are an IFluidCodeResolver (used for loading code into the container), an IDocumentServiceFactory (used for connecting to the Fluid service), and an IUrlResolver (used for resolving URLs used in API calls against the Loader and Container).

Usage

BaseHost provides a method .initializeContainer() which will retrieve a Container from the given url, and if necessary initializing it with the given code in the process.

const container = await baseHost.initializeContainer(url, codeDetails);

Once the container is retrieved and initialized this way, requests can be made against it.

BaseHost also provides a method .requestFluidObject() for retrieving Fluid objects directly (bypassing the Container) for convenience.

const fluidObject = await baseHost.requestFluidObject(url);

The Loader can be also be retrieved via .getLoader().

const loader = await baseHost.getLoader();

initializeContainerCode()

If the full facilities of a BaseHost aren't needed, the helper initializeContainerCode() can be used directly to initialize a container with code.

await initializeContainerCode(container, codeDetails);

After this promise resolves, the container will be initialized, though the context change may not have occurred yet.

Readme

Keywords

none

Package Sidebar

Install

npm i @fluidframework/base-host

Weekly Downloads

1

Version

0.50.1

License

MIT

Unpacked Size

1.63 MB

Total Files

50

Last publish

Collaborators

  • ms-fluid-bot
  • curtisman