Interface IEventListener
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
Interface for listening to JavaScript events.
public interface IEventListener : IAsyncDisposable
- Inherited Members
- Extension Methods
Methods
SubscribeGlobal<T>(string, int, Func<object, Task>)
Listens to a JavaScript event on the document itself.
Task<Guid> SubscribeGlobal<T>(string eventName, int throttleInterval, Func<object, Task> callback)
Parameters
eventName
stringName of the DOM event without "on".
throttleInterval
intThe delay between the last time the event occurred and the callback is fired. Set to zero if no delay is requested.
callback
Func<object, Task>The method that is invoked when the DOM element event is fired. The object will be of type T.
Returns
- Task<Guid>
A unique identifier for the event subscription. Should be used to cancel the subscription.
Type Parameters
T
The type of the event args, for instance, MouseEventArgs for mousemove.
Subscribe<T>(string, string, string, int, Func<object, Task>)
Listens to a JavaScript event.
Task<Guid> Subscribe<T>(string eventName, string elementId, string projectionName, int throttleInterval, Func<object, Task> callback)
Parameters
eventName
stringName of the DOM event without "on".
elementId
stringThe value of the id field of the DOM element.
projectionName
stringThe name of a JS function (relative to window) that is used to project the event before it is sent back to .NET. Can be null if no projection is needed.
throttleInterval
intThe delay between the last time the event occurred and the callback is fired. Set to zero if no delay is requested.
callback
Func<object, Task>The method that is invoked when the DOM element event is fired. The object will be of type T.
Returns
- Task<Guid>
A unique identifier for the event subscription. Should be used to cancel the subscription.
Type Parameters
T
The type of the event args, for instance, MouseEventArgs for mousemove.
Unsubscribe(Guid)
Cancels (unsubscribes) the listening to a DOM event, previously connected by Subscribe.
Task<bool> Unsubscribe(Guid key)
Parameters
key
GuidThe unique event identifier.