AboutSupportDeveloper GuideVersion 19.1.23

Interface HomeRegistration

Response from home registration which includes metadata and a function to inject search string into home search

Hierarchy

Properties

clientAPIVersion: string

Client API version

This is the version of the Workspace client API that is being used to register the component.

workspaceVersion: string

Workspace version

This is the version of Workspace that the Workspace component is running on. This could be used to determine if the component is running on a version of Workspace that supports a particular feature.

Methods

  • Function to inject search string into home search

    Parameters

    • query: string

      search string

    Returns Promise<void>

    A promise that resolves when the search string has been injected into home search

    Remarks

    Calling this will switch the active provider within Home to the provider that was registered with this HomeRegistration.

    Throws

    An error if the Home Provider is no longer registered.

    Example

    Injecting a search string into Home search

    import { Home, type CLIProvider } from '@openfin/workspace';

    import { fetchMySearchResults } from "./my-fetch-implementation";

    const searchQueryMap: Map<string, (query: string) => void> = new Map();

    // CLIProvider or HomeProvider
    const myCLIProvider: CLIProvider = {
    id: "my-cli-provider",
    title: "My CLI Provider",
    icon: "https://google.com/favicon.ico",
    onUserInput: (req) => fetchMySearchResults(req.query)
    };

    // register home and get back a function to inject search string into home search
    const { setSearchQuery } = await Home.register(myCLIProvider);

    // Store set query function in a map if you're using multiple providers
    searchQueryMap.set(myCLIProvider.id, setSearchQuery);

    // Call the set query function for a specific provider the search should be injected into
    const searchButton = document.createElement('button');
    searchButton.innerHTML = 'Search';
    document.body.appendChild(searchButton);

    searchButton.addEventListener('click', () => {
    searchQueryMap.get('my-cli-provider')?.('my search string');
    });