Skip to content

Commit fcdaf7f

Browse files
committed
refactor: 更改返回值为可为空对象
1 parent a1b8cbf commit fcdaf7f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/BootstrapBlazor/Services/DefaultNetworkMonitorService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public DefaultNetowrkMonitorService(IJSRuntime jsRuntime)
3434
/// <summary>
3535
/// <inheritdoc/>
3636
/// </summary>
37-
public async Task<NetworkMonitorState> GetNetworkMonitorState(CancellationToken token = default)
37+
public async Task<NetworkMonitorState?> GetNetworkMonitorState(CancellationToken token = default)
3838
{
3939
_module ??= await LoadModule();
40-
return await _module.InvokeAsync<NetworkMonitorState?>("getNetworkInfo", token) ?? new();
40+
return await _module.InvokeAsync<NetworkMonitorState?>("getNetworkInfo", token);
4141
}
4242

4343
/// <summary>

src/BootstrapBlazor/Services/INetworkMonitorService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public interface INetworkMonitorService
1616
/// <param name="token">A cancellation token that can be used to cancel the operation.</param>
1717
/// <returns>A task representing the asynchronous operation. The task result contains the current <see
1818
/// cref="NetworkMonitorState"/>.</returns>
19-
Task<NetworkMonitorState> GetNetworkMonitorState(CancellationToken token = default);
19+
Task<NetworkMonitorState?> GetNetworkMonitorState(CancellationToken token = default);
2020

2121
/// <summary>
2222
/// Registers a callback to be invoked when the network monitor state changes.

0 commit comments

Comments
 (0)