Class: SearchExecution<T>
Event emitter for search execution events. Extends the EventEmitter class to handle events related to search execution.
Extends
Type Parameters
T
T
Implements
SearchExecution<T>
Constructors
Constructor
new SearchExecution<
T>():SearchExecution<T>
Constructs a new SearchExecution instance. Initializes the search execution
with a Promise to track the search result.
Returns
SearchExecution<T>
Overrides
EventEmitter<SearchExecutionEventMap<T>>.constructor
Properties
result
result:
Promise<T>
A Promise representing the result of the search execution.
Implementation of
SearchExecution.result
state
state:
SearchExecutionState=SearchExecutionState.Executing
The current state of the search execution.
Implementation of
SearchExecution.state
Methods
addEventListener()
addEventListener<
K>(type,listener):void
Register a function that will be called whenever the specified event is delivered.
Type Parameters
K
K extends keyof
SearchExecutionEventMap<T>
A generic type representing the key of the event type.
Parameters
type
K
String representing the event type to listen for.
listener
(…e) => void
The function that will be executed when an event of the specified type occurs.
Returns
void
Implementation of
SearchExecution.addEventListener
Inherited from
EventEmitter.addEventListener
cancel()
cancel():
void
Cancels the search execution. Sets the search execution state to “canceled” and dispatches a searchCanceled event.
Returns
void
Implementation of
SearchExecution.cancel
dispatchEvent()
dispatchEvent<
K>(type,args):void
Dispatches an event to all registered listeners.
Type Parameters
K
K extends keyof
SearchExecutionEventMap<T>
A generic type representing the key of the event type.
Parameters
type
K
String representing the event type to dispatch.
args
Parameters<SearchExecutionEventMap<T>[K]>
The data associated with the event.
Returns
void
Implementation of
SearchExecution.dispatchEvent
Inherited from
EventEmitter.dispatchEvent
onErrorOccurred()
onErrorOccurred(
error):void
Handles errors that occur during the search execution. Rejects the search Promise with the error and dispatches an errorOccurred event.
Parameters
error
Error
The error that occurred during the search execution.
Returns
void
Implementation of
SearchExecution.onErrorOccurred
onSearchFinished()
onSearchFinished(
result):void
Handles the completion of the search execution. Sets the search execution state to “finished”, resolves the search Promise with the result, and dispatches a searchFinished event.
Parameters
result
T
The result of the search execution.
Returns
void
Implementation of
SearchExecution.onSearchFinished
onSearchResultsFound()
onSearchResultsFound(
result):void
Handles the discovery of search results. Dispatches a searchResultsFound event.
Parameters
result
T
The result of the search execution.
Returns
void
Implementation of
SearchExecution.onSearchResultsFound
onSearchStarted()
onSearchStarted(
result):void
Handles the start of the search execution. Sets the search execution state to “executing” and dispatches a searchStarted event.
Parameters
result
T
The result of the search execution.
Returns
void
Implementation of
SearchExecution.onSearchStarted
removeAllListeners()
removeAllListeners<
K>(type):void
Remove all listeners for a given event.
Type Parameters
K
K extends keyof
SearchExecutionEventMap<T>
A generic type representing the key of the event type.
Parameters
type
K
String representing the event for which to remove all listeners.
Returns
void
Implementation of
SearchExecution.removeAllListeners
Inherited from
EventEmitter.removeAllListeners
removeEventListener()
removeEventListener<
K>(type,listener):void
Removes an event listener previously registered with addEventListener.
Type Parameters
K
K extends keyof
SearchExecutionEventMap<T>
A generic type representing the key of the event type.
Parameters
type
K
String representing the event for which to remove an event listener.
listener
(…e) => void
The event listener function of the event handler to remove from the event target.
Returns
void
Implementation of
SearchExecution.removeEventListener
Inherited from
EventEmitter.removeEventListener