@@ -163,6 +163,7 @@ public async Task<ushort> GetReadyStateAsync()
163163 /// Gets the error object reference which will be <see langword="null"/> if no error occured.
164164 /// </summary>
165165 /// <returns>A nullable IJSObjectReference because it was out of scope to wrap the Exception API.</returns>
166+ // TODO: This should return actual error object from Blazor.WebIDL.
166167 public async Task < IJSObjectReference ? > GetErrorAsync ( )
167168 {
168169 IJSObjectReference helper = await fileApiHelperTask . Value ;
@@ -172,40 +173,47 @@ public async Task<ushort> GetReadyStateAsync()
172173 /// <summary>
173174 /// Invoked when a load starts.
174175 /// </summary>
176+ [ Obsolete ( "This will be removed in the next major release as in favor of AddOnLoadStartEventListenerAsync and RemoveOnLoadStartEventListenerAsync as they are more memory safe." ) ]
175177 [ JsonIgnore ]
176178 public Func < ProgressEvent , Task > ? OnLoadStart { get ; set ; }
177179
178180 /// <summary>
179181 /// Invoked when the progress of a load changes which includes when it ends.
180182 /// </summary>
183+ [ Obsolete ( "This will be removed in the next major release as in favor of AddOnProgressEventListenerAsync and RemoveOnProgressEventListenerAsync as they are more memory safe." ) ]
181184 [ JsonIgnore ]
182185 public Func < ProgressEvent , Task > ? OnProgress { get ; set ; }
183186
184187 /// <summary>
185188 /// Invoked when a load ends successfully.
186189 /// </summary>
190+ [ Obsolete ( "This will be removed in the next major release as in favor of AddOnLoadEventListenerAsync and RemoveOnLoadEventListenerAsync as they are more memory safe." ) ]
187191 [ JsonIgnore ]
188192 public Func < ProgressEvent , Task > ? OnLoad { get ; set ; }
189193
190194 /// <summary>
191195 /// Invoked when a load is aborted.
192196 /// </summary>
197+ [ Obsolete ( "This will be removed in the next major release as in favor of AddOnAbortEventListenerAsync and RemoveOnAbortEventListenerAsync as they are more memory safe." ) ]
193198 [ JsonIgnore ]
194199 public Func < ProgressEvent , Task > ? OnAbort { get ; set ; }
195200
196201 /// <summary>
197202 /// Invoked when a load fails due to an error.
198203 /// </summary>
204+ [ Obsolete ( "This will be removed in the next major release as in favor of AddOnErrorEventListenerAsync and RemoveOnErrorEventListenerAsync as they are more memory safe." ) ]
199205 [ JsonIgnore ]
200206 public Func < ProgressEvent , Task > ? OnError { get ; set ; }
201207
202208 /// <summary>
203209 /// Invoked when a load finishes successfully or not.
204210 /// </summary>
211+ [ Obsolete ( "This will be removed in the next major release as in favor of AddOnLoadEndEventListenerAsync and RemoveOnLoadEndEventListenerAsync as they are more memory safe." ) ]
205212 [ JsonIgnore ]
206213 public Func < ProgressEvent , Task > ? OnLoadEnd { get ; set ; }
207214
208- /// <summary>Internal method that will be removed in next major release.</summary>
215+ /// <summary>Internal method.</summary>
216+ [ Obsolete ( "This will be removed in the next major release." ) ]
209217 [ JSInvokable ]
210218 public async Task InvokeOnLoadStartAsync ( IJSObjectReference jsProgressEvent )
211219 {
@@ -217,7 +225,8 @@ public async Task InvokeOnLoadStartAsync(IJSObjectReference jsProgressEvent)
217225 await OnLoadStart . Invoke ( new ProgressEvent ( JSRuntime , jsProgressEvent , new ( ) { DisposesJSReference = true } ) ) ;
218226 }
219227
220- /// <summary>Internal method that will be removed in next major release.</summary>
228+ /// <summary>Internal method.</summary>
229+ [ Obsolete ( "This will be removed in the next major release." ) ]
221230 [ JSInvokable ]
222231 public async Task InvokeOnProgressAsync ( IJSObjectReference jsProgressEvent )
223232 {
@@ -229,7 +238,8 @@ public async Task InvokeOnProgressAsync(IJSObjectReference jsProgressEvent)
229238 await OnProgress . Invoke ( new ProgressEvent ( JSRuntime , jsProgressEvent , new ( ) { DisposesJSReference = true } ) ) ;
230239 }
231240
232- /// <summary>Internal method that will be removed in next major release.</summary>
241+ /// <summary>Internal method.</summary>
242+ [ Obsolete ( "This will be removed in the next major release." ) ]
233243 [ JSInvokable ]
234244 public async Task InvokeOnLoadAsync ( IJSObjectReference jsProgressEvent )
235245 {
@@ -241,7 +251,8 @@ public async Task InvokeOnLoadAsync(IJSObjectReference jsProgressEvent)
241251 await OnLoad . Invoke ( new ProgressEvent ( JSRuntime , jsProgressEvent , new ( ) { DisposesJSReference = true } ) ) ;
242252 }
243253
244- /// <summary>Internal method that will be removed in next major release.</summary>
254+ /// <summary>Internal method.</summary>
255+ [ Obsolete ( "This will be removed in the next major release." ) ]
245256 [ JSInvokable ]
246257 public async Task InvokeOnAbortAsync ( IJSObjectReference jsProgressEvent )
247258 {
@@ -253,7 +264,8 @@ public async Task InvokeOnAbortAsync(IJSObjectReference jsProgressEvent)
253264 await OnAbort . Invoke ( new ProgressEvent ( JSRuntime , jsProgressEvent , new ( ) { DisposesJSReference = true } ) ) ;
254265 }
255266
256- /// <summary>Internal method that will be removed in next major release.</summary>
267+ /// <summary>Internal method.</summary>
268+ [ Obsolete ( "This will be removed in the next major release." ) ]
257269 [ JSInvokable ]
258270 public async Task InvokeOnErrorAsync ( IJSObjectReference jsProgressEvent )
259271 {
@@ -265,7 +277,8 @@ public async Task InvokeOnErrorAsync(IJSObjectReference jsProgressEvent)
265277 await OnError . Invoke ( new ProgressEvent ( JSRuntime , jsProgressEvent , new ( ) { DisposesJSReference = true } ) ) ;
266278 }
267279
268- /// <summary>Internal method that will be removed in next major release.</summary>
280+ /// <summary>Internal method.</summary>
281+ [ Obsolete ( "This will be removed in the next major release." ) ]
269282 [ JSInvokable ]
270283 public async Task InvokeOnLoadEndAsync ( IJSObjectReference jsProgressEvent )
271284 {
@@ -277,6 +290,126 @@ public async Task InvokeOnLoadEndAsync(IJSObjectReference jsProgressEvent)
277290 await OnLoadEnd . Invoke ( new ProgressEvent ( JSRuntime , jsProgressEvent , new ( ) { DisposesJSReference = true } ) ) ;
278291 }
279292
293+ /// <summary>
294+ /// Adds an <see cref="EventListener{TEvent}"/> for when a load is started.
295+ /// </summary>
296+ /// <param name="callback">Callback that will be invoked when the event is dispatched.</param>
297+ /// <param name="options"><inheritdoc cref="EventTarget.AddEventListenerAsync{TEvent}(string, EventListener{TEvent}?, AddEventListenerOptions?)" path="/param[@name='options']"/></param>
298+ public async Task AddOnLoadStartEventListenerAsync ( EventListener < ProgressEvent > callback , AddEventListenerOptions ? options = null )
299+ {
300+ await AddEventListenerAsync ( "loadstart" , callback , options ) ;
301+ }
302+
303+ /// <summary>
304+ /// Removes the event listener from the event listener list if it has been parsed to <see cref="AddOnLoadStartEventListenerAsync"/> previously.
305+ /// </summary>
306+ /// <param name="callback">The callback <see cref="EventListener{TEvent}"/> that you want to stop listening to events.</param>
307+ /// <param name="options"><inheritdoc cref="EventTarget.RemoveEventListenerAsync{TEvent}(string, EventListener{TEvent}?, EventListenerOptions?)" path="/param[@name='options']"/></param>
308+ public async Task RemoveOnLoadStartEventListenerAsync ( EventListener < ProgressEvent > callback , EventListenerOptions ? options = null )
309+ {
310+ await RemoveEventListenerAsync ( "loadstart" , callback , options ) ;
311+ }
312+
313+ /// <summary>
314+ /// Adds an <see cref="EventListener{TEvent}"/> for when the progress of a load changes which includes when it ends.
315+ /// </summary>
316+ /// <param name="callback">Callback that will be invoked when the event is dispatched.</param>
317+ /// <param name="options"><inheritdoc cref="EventTarget.AddEventListenerAsync{TEvent}(string, EventListener{TEvent}?, AddEventListenerOptions?)" path="/param[@name='options']"/></param>
318+ public async Task AddOnProgressEventListenerAsync ( EventListener < ProgressEvent > callback , AddEventListenerOptions ? options = null )
319+ {
320+ await AddEventListenerAsync ( "progress" , callback , options ) ;
321+ }
322+
323+ /// <summary>
324+ /// Removes the event listener from the event listener list if it has been parsed to <see cref="AddOnProgressEventListenerAsync"/> previously.
325+ /// </summary>
326+ /// <param name="callback">The callback <see cref="EventListener{TEvent}"/> that you want to stop listening to events.</param>
327+ /// <param name="options"><inheritdoc cref="EventTarget.RemoveEventListenerAsync{TEvent}(string, EventListener{TEvent}?, EventListenerOptions?)" path="/param[@name='options']"/></param>
328+ public async Task RemoveOnProgressEventListenerAsync ( EventListener < ProgressEvent > callback , EventListenerOptions ? options = null )
329+ {
330+ await RemoveEventListenerAsync ( "progress" , callback , options ) ;
331+ }
332+
333+ /// <summary>
334+ /// Adds an <see cref="EventListener{TEvent}"/> for when a load ends successfully.
335+ /// </summary>
336+ /// <param name="callback">Callback that will be invoked when the event is dispatched.</param>
337+ /// <param name="options"><inheritdoc cref="EventTarget.AddEventListenerAsync{TEvent}(string, EventListener{TEvent}?, AddEventListenerOptions?)" path="/param[@name='options']"/></param>
338+ public async Task AddOnLoadEventListenerAsync ( EventListener < ProgressEvent > callback , AddEventListenerOptions ? options = null )
339+ {
340+ await AddEventListenerAsync ( "load" , callback , options ) ;
341+ }
342+
343+ /// <summary>
344+ /// Removes the event listener from the event listener list if it has been parsed to <see cref="AddOnLoadEventListenerAsync"/> previously.
345+ /// </summary>
346+ /// <param name="callback">The callback <see cref="EventListener{TEvent}"/> that you want to stop listening to events.</param>
347+ /// <param name="options"><inheritdoc cref="EventTarget.RemoveEventListenerAsync{TEvent}(string, EventListener{TEvent}?, EventListenerOptions?)" path="/param[@name='options']"/></param>
348+ public async Task RemoveOnLoadEventListenerAsync ( EventListener < ProgressEvent > callback , EventListenerOptions ? options = null )
349+ {
350+ await RemoveEventListenerAsync ( "load" , callback , options ) ;
351+ }
352+
353+ /// <summary>
354+ /// Adds an <see cref="EventListener{TEvent}"/> for when a load is aborted.
355+ /// </summary>
356+ /// <param name="callback">Callback that will be invoked when the event is dispatched.</param>
357+ /// <param name="options"><inheritdoc cref="EventTarget.AddEventListenerAsync{TEvent}(string, EventListener{TEvent}?, AddEventListenerOptions?)" path="/param[@name='options']"/></param>
358+ public async Task AddOnAbortEventListenerAsync ( EventListener < ProgressEvent > callback , AddEventListenerOptions ? options = null )
359+ {
360+ await AddEventListenerAsync ( "abort" , callback , options ) ;
361+ }
362+
363+ /// <summary>
364+ /// Removes the event listener from the event listener list if it has been parsed to <see cref="AddOnAbortEventListenerAsync"/> previously.
365+ /// </summary>
366+ /// <param name="callback">The callback <see cref="EventListener{TEvent}"/> that you want to stop listening to events.</param>
367+ /// <param name="options"><inheritdoc cref="EventTarget.RemoveEventListenerAsync{TEvent}(string, EventListener{TEvent}?, EventListenerOptions?)" path="/param[@name='options']"/></param>
368+ public async Task RemoveOnAbortEventListenerAsync ( EventListener < ProgressEvent > callback , EventListenerOptions ? options = null )
369+ {
370+ await RemoveEventListenerAsync ( "abort" , callback , options ) ;
371+ }
372+
373+ /// <summary>
374+ /// Adds an <see cref="EventListener{TEvent}"/> for when a load fails due to an error.
375+ /// </summary>
376+ /// <param name="callback">Callback that will be invoked when the event is dispatched.</param>
377+ /// <param name="options"><inheritdoc cref="EventTarget.AddEventListenerAsync{TEvent}(string, EventListener{TEvent}?, AddEventListenerOptions?)" path="/param[@name='options']"/></param>
378+ public async Task AddOnErrorEventListenerAsync ( EventListener < ProgressEvent > callback , AddEventListenerOptions ? options = null )
379+ {
380+ await AddEventListenerAsync ( "error" , callback , options ) ;
381+ }
382+
383+ /// <summary>
384+ /// Removes the event listener from the event listener list if it has been parsed to <see cref="AddOnErrorEventListenerAsync"/> previously.
385+ /// </summary>
386+ /// <param name="callback">The callback <see cref="EventListener{TEvent}"/> that you want to stop listening to events.</param>
387+ /// <param name="options"><inheritdoc cref="EventTarget.RemoveEventListenerAsync{TEvent}(string, EventListener{TEvent}?, EventListenerOptions?)" path="/param[@name='options']"/></param>
388+ public async Task RemoveOnErrorEventListenerAsync ( EventListener < ProgressEvent > callback , EventListenerOptions ? options = null )
389+ {
390+ await RemoveEventListenerAsync ( "error" , callback , options ) ;
391+ }
392+
393+ /// <summary>
394+ /// Adds an <see cref="EventListener{TEvent}"/> for when a load finishes successfully or not.
395+ /// </summary>
396+ /// <param name="callback">Callback that will be invoked when the event is dispatched.</param>
397+ /// <param name="options"><inheritdoc cref="EventTarget.AddEventListenerAsync{TEvent}(string, EventListener{TEvent}?, AddEventListenerOptions?)" path="/param[@name='options']"/></param>
398+ public async Task AddOnLoadEndEventListenerAsync ( EventListener < ProgressEvent > callback , AddEventListenerOptions ? options = null )
399+ {
400+ await AddEventListenerAsync ( "error" , callback , options ) ;
401+ }
402+
403+ /// <summary>
404+ /// Removes the event listener from the event listener list if it has been parsed to <see cref="AddOnLoadEndEventListenerAsync"/> previously.
405+ /// </summary>
406+ /// <param name="callback">The callback <see cref="EventListener{TEvent}"/> that you want to stop listening to events.</param>
407+ /// <param name="options"><inheritdoc cref="EventTarget.RemoveEventListenerAsync{TEvent}(string, EventListener{TEvent}?, EventListenerOptions?)" path="/param[@name='options']"/></param>
408+ public async Task RemoveOnLoadEndEventListenerAsync ( EventListener < ProgressEvent > callback , EventListenerOptions ? options = null )
409+ {
410+ await RemoveEventListenerAsync ( "error" , callback , options ) ;
411+ }
412+
280413 /// <inheritdoc/>
281414 public new async ValueTask DisposeAsync ( )
282415 {
0 commit comments