Skip to content

Commit f4967fd

Browse files
committed
Added event handlers for BackgroundFetch APi, Payments API, Cookies API, and Content indexing to ServiceWorkerEventHandler
1 parent d215ddd commit f4967fd

9 files changed

Lines changed: 447 additions & 58 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Microsoft.JSInterop;
2+
using SpawnDev.BlazorJS.JSObjects;
3+
4+
namespace SpawnDev.BlazorJS.WebWorkers
5+
{
6+
/// <summary>
7+
/// An Event that was initially missed while Blazor was loading, but was held using waitUntil() so that Blazor can handle it.<br />
8+
/// </summary>
9+
internal class MissedBackgroundFetchEvent : BackgroundFetchEvent, IMissedEvent
10+
{
11+
///<inheritdoc/>
12+
public MissedBackgroundFetchEvent(IJSInProcessObjectReference _ref) : base(_ref) { }
13+
///<inheritdoc/>
14+
public void WaitResolve() => JSRef!.CallVoid("waitResolve");
15+
///<inheritdoc/>
16+
public void WaitReject() => JSRef!.CallVoid("waitReject");
17+
///<inheritdoc/>
18+
public bool IsExtended => !JSRef!.IsUndefined("waitResolve");
19+
}
20+
}
21+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Microsoft.JSInterop;
2+
using SpawnDev.BlazorJS.JSObjects;
3+
4+
namespace SpawnDev.BlazorJS.WebWorkers
5+
{
6+
/// <summary>
7+
/// An Event that was initially missed while Blazor was loading, but was held using waitUntil() so that Blazor can handle it.<br />
8+
/// </summary>
9+
internal class MissedBackgroundFetchUpdateUIEvent : BackgroundFetchUpdateUIEvent, IMissedEvent
10+
{
11+
///<inheritdoc/>
12+
public MissedBackgroundFetchUpdateUIEvent(IJSInProcessObjectReference _ref) : base(_ref) { }
13+
///<inheritdoc/>
14+
public void WaitResolve() => JSRef!.CallVoid("waitResolve");
15+
///<inheritdoc/>
16+
public void WaitReject() => JSRef!.CallVoid("waitReject");
17+
///<inheritdoc/>
18+
public bool IsExtended => !JSRef!.IsUndefined("waitResolve");
19+
}
20+
}
21+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.JSInterop;
2+
using SpawnDev.BlazorJS.JSObjects;
3+
4+
namespace SpawnDev.BlazorJS.WebWorkers
5+
{
6+
/// <summary>
7+
/// An Event that was initially missed while Blazor was loading, but was held using waitUntil() so that Blazor can handle it.<br />
8+
/// </summary>
9+
internal class MissedCanMakePaymentEvent : CanMakePaymentEvent
10+
{
11+
///<inheritdoc/>
12+
public MissedCanMakePaymentEvent(IJSInProcessObjectReference _ref) : base(_ref) { }
13+
/// <summary>
14+
/// Resolves the CanMakePaymentEvent.<br />
15+
/// </summary>
16+
/// <param name="response"></param>
17+
public void ResponseResolve(bool response) => JSRef!.CallVoid("responseResolve", response);
18+
/// <summary>
19+
/// Rejects the CanMakePaymentEvent.<br />
20+
/// </summary>
21+
public void ResponseReject() => JSRef!.CallVoid("responseReject");
22+
///<inheritdoc/>
23+
public bool IsExtended => !JSRef!.IsUndefined("responseResolve");
24+
}
25+
}
26+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Microsoft.JSInterop;
2+
using SpawnDev.BlazorJS.JSObjects;
3+
4+
namespace SpawnDev.BlazorJS.WebWorkers
5+
{
6+
/// <summary>
7+
/// An Event that was initially missed while Blazor was loading, but was held using waitUntil() so that Blazor can handle it.<br />
8+
/// </summary>
9+
internal class MissedContentIndexEvent : ContentIndexEvent, IMissedEvent
10+
{
11+
///<inheritdoc/>
12+
public MissedContentIndexEvent(IJSInProcessObjectReference _ref) : base(_ref) { }
13+
///<inheritdoc/>
14+
public void WaitResolve() => JSRef!.CallVoid("waitResolve");
15+
///<inheritdoc/>
16+
public void WaitReject() => JSRef!.CallVoid("waitReject");
17+
///<inheritdoc/>
18+
public bool IsExtended => !JSRef!.IsUndefined("waitResolve");
19+
}
20+
}
21+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Microsoft.JSInterop;
2+
using SpawnDev.BlazorJS.JSObjects;
3+
4+
namespace SpawnDev.BlazorJS.WebWorkers
5+
{
6+
/// <summary>
7+
/// An Event that was initially missed while Blazor was loading, but was held using waitUntil() so that Blazor can handle it.<br />
8+
/// </summary>
9+
internal class MissedExtendableCookieChangeEvent : ExtendableCookieChangeEvent, IMissedEvent
10+
{
11+
///<inheritdoc/>
12+
public MissedExtendableCookieChangeEvent(IJSInProcessObjectReference _ref) : base(_ref) { }
13+
///<inheritdoc/>
14+
public void WaitResolve() => JSRef!.CallVoid("waitResolve");
15+
///<inheritdoc/>
16+
public void WaitReject() => JSRef!.CallVoid("waitReject");
17+
///<inheritdoc/>
18+
public bool IsExtended => !JSRef!.IsUndefined("waitResolve");
19+
}
20+
}
21+

SpawnDev.BlazorJS.WebWorkers/MissedEvents/MissedFetchEvent.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public MissedFetchEvent(IJSInProcessObjectReference _ref) : base(_ref) { }
1919
/// Rejects the FetchEvent.<br />
2020
/// </summary>
2121
public void ResponseReject() => JSRef!.CallVoid("responseReject");
22+
///<inheritdoc/>
23+
public bool IsExtended => !JSRef!.IsUndefined("responseResolve");
2224
}
2325
}
2426

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Microsoft.JSInterop;
2+
using SpawnDev.BlazorJS.JSObjects;
3+
4+
namespace SpawnDev.BlazorJS.WebWorkers
5+
{
6+
/// <summary>
7+
/// An Event that was initially missed while Blazor was loading, but was held using waitUntil() so that Blazor can handle it.<br />
8+
/// </summary>
9+
internal class MissedPaymentRequestEvent : PaymentRequestEvent, IMissedEvent
10+
{
11+
///<inheritdoc/>
12+
public MissedPaymentRequestEvent(IJSInProcessObjectReference _ref) : base(_ref) { }
13+
///<inheritdoc/>
14+
public void WaitResolve() => JSRef!.CallVoid("waitResolve");
15+
///<inheritdoc/>
16+
public void WaitReject() => JSRef!.CallVoid("waitReject");
17+
///<inheritdoc/>
18+
public bool IsExtended => !JSRef!.IsUndefined("waitResolve");
19+
}
20+
}
21+

0 commit comments

Comments
 (0)