Setting Up iModel.js Presentation Library

In addition to setting up imodeljs-core there are some steps that API consumers must do before the library can be used.

Backend

  1. Initialize the library:

    `typescript import { Presentation } from "@bentley/presentation-backend";

// initialize presentation-backend Presentation.initialize({ rulesetDirectories: [path.join("assets", "presentation_rules")], localeDirectories: [path.join("assets", "locales")], });


2. Register `PresentationRpcInterface` (amongst other RPC interfaces):

  ```typescript
  import { PresentationRpcInterface } from "@bentley/presentation-common";
  const rpcs = [...otherRpcInterfaces, PresentationRpcInterface];
    ElectronRpcManager.initializeImpl({}, rpcs);

Frontend

  1. Initialize the library:

    import { Presentation } from "@bentley/presentation-frontend";
       Presentation.initialize({
       // specify `clientId` so Presentation framework can share caches
       // between sessions for the same clients
       clientId: MyAppFrontend.getClientId(),
    
       // specify locale for localizing presentation data
       activeLocale: IModelApp.i18n.languageList()[0],
     });
  2. Register PresentationRpcInterface (amongst other RPC interfaces):

    import { PresentationRpcInterface } from "@bentley/presentation-common";
    const rpcs = [...otherRpcInterfaces, PresentationRpcInterface];
       const rpcConfiguration = BentleyCloudRpcManager.initializeClient(rpcParams, rpcs);

Last Updated: 20 September, 2019