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
eventNamestringName of the DOM event without "on".
throttleIntervalintThe delay between the last time the event occurred and the callback is fired. Set to zero if no delay is requested.
callbackFunc<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
TThe 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
eventNamestringName of the DOM event without "on".
elementIdstringThe value of the id field of the DOM element.
projectionNamestringThe 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.
throttleIntervalintThe delay between the last time the event occurred and the callback is fired. Set to zero if no delay is requested.
callbackFunc<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
TThe 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
keyGuidThe unique event identifier.