Function to inject search string into home search
search string
Promise
import Home, 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');
});
Generated using TypeDoc
Reponse from home registration which includes metadata and a function to inject search string into home search