@deephaven/jsapi-bootstrap
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

@deephaven/jsapi-bootstrap

This is a library to bootstrap load the JS API. It provides functionality to load the API and set it in a context object, or to set it globally to retain legacy behaviour. Will display an error if unable to load the API.

Install

npm install --save @deephaven/jsapi-bootstrap

Usage

Using Context

import { ApiBootstrap, useApi } from '@deephaven/jsapi-bootstrap';

function MyComponent() {
  const api = useApi();

  ...
}

<ApiBootstrap apiUrl={API_URL}>
  <MyComponent />
</ApiBootstrap>;

Using API globally (legacy behaviour)

If you're using the JSAPI shim or relying on the API to be set globally, you'll need to lazily load your component first so the API is set before imports attempt to use it.

// App.tsx
import { ApiBootstrap } from '@deephaven/jsapi-bootstrap';

const MyComponent = React.lazy(() => import('./MyComponent'));

<ApiBootstrap apiUrl={API_URL} setGlobally>
    <Suspense fallback={<div>Loading...</div>}>
      <MyComponent />
    </Suspense>
</ApiBootstrap>;

// MyComponent.tsx
import dh from '@deephaven/jsapi-shim';
function MyComponent() {
  const client = new dh.CoreClient(...);

  ...
}

/@deephaven/jsapi-bootstrap/

    Package Sidebar

    Install

    npm i @deephaven/jsapi-bootstrap

    Weekly Downloads

    2,389

    Version

    1.5.0

    License

    Apache-2.0

    Unpacked Size

    85.5 kB

    Total Files

    47

    Last publish

    Collaborators

    • vbabich
    • mofojed
    • mikebender
    • niloc132
    • nbauernfeind
    • jnumainville
    • deephaven-bot
    • bingles