API: SearchClient
The Search Client allows for any window launched by Finsemble to act as a search provider or query against the registered providers.
See the Search tutorial for an overview of using the Search Client.
Functions
invokeItemAction
▸ invokeItemAction(item
, action
): void
Call this when you want to trigger an action associated to a returned item. There can be multiple actions associated with a result item and only one should be fired at a time.
FSBL.Clients.SearchClient.invokeItemAction(resultItem, action);
Parameters
Name | Type | Description |
---|---|---|
item | any | This is the search result item. |
action | Object | The action object |
action.name | string | The name of the action that you would like to fire. |
Returns
void
invokeProviderAction
▸ invokeProviderAction(provider
): void
Call this when you want to trigger an action associated with a provider. Not all providers register an action handler.
FSBL.Clients.SearchClient.invokeProviderAction(provider);
Parameters
Name | Type | Description |
---|---|---|
provider | Object | Object containing the information needed to trigger an action. |
provider.channel | string | The channel identifier which is being requested to conduct it's action |
Returns
void
register
▸ register(params
, cb?
): StandardPromise
<{ status
: string
}>
Register a provider with the search service.
{ status : "success" }
is resolved or called back when successful.
FSBL.Clients.SearchClient.register({
name: "MyProvider",
searchCallback: searchApplications,
itemActionCallback: itemActionCallback,
providerActionTitle: providerActionTitle,
providerActionCallback:providerActionCallback
},
(err, response) => {
//provider has been registered
});
Parameters
Name | Type | Description |
---|---|---|
params | Object | Params object |
params.itemActionCallback? | Function | A function that is called when an item action is fired. |
params.name | string | The name of the provider. |
params.providerActionCallback? | Function | A function that is called when a provider action is fired. |
params.providerActionTitle? | null | string | The title of the provider action. |
params.searchCallback | Function | A function called when a search is initialized. |
cb? | StandardErrorCallback <{ status : string }> | Callback to be invoked when the provider is registered. |
Returns
StandardPromise
<{ status
: string
}>
search
▸ search(params
, cb
): Promise
<void
>
This initiates a search.
The promise will resolve when the search has been successfully initiated but results are only returned on the callback handler. This callback handler may be called multiple times. Each time, the complete set of search results is returned. There is no indication when all results have returned.
FSBL.Clients.SearchClient.search({
text: "Chart",
(err, response) => {
//Search results will be returned here
});
Parameters
Name | Type | Description |
---|---|---|
params | Object | Params object |
params.text | string | The text to be searched |
params.windowName? | string | Optional. Will be set to the window which is invoking the API method. |
cb | Function | Callback to be called as search results for each provider are returned. Results are combined as they come in. So every response will have the complete list of results that have been returned. Example: You have two providers; provider one returns results first: you'll have an array with just provider one's data. Once provider two returns, you'll have results for provider one and provider two. |
Returns
Promise
<void
>
unregister
▸ unregister(params
, cb?
): Promise
<void
>
Remove a provider. This can only be done from the window that registered the provider.
FSBL.Clients.SearchClient.unregister({ name: "MyProvider" }, function(){ });
Parameters
Name | Type | Description |
---|---|---|
params | Object | |
params.name | string | The name of the provider to be removed. |
cb? | Function | The callback to be invoked after the method completes successfully. |
Returns
Promise
<void
>