-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2de9186
commit d5010c6
Showing
3 changed files
with
22 additions
and
29 deletions.
There are no files selected for viewing
8 changes: 1 addition & 7 deletions
8
src/AstroPanda.Blazor.Toolkit/Services/IPersistentStateService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/AstroPanda.Blazor.Toolkit/Services/PeristentStateService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
using Microsoft.JSInterop; | ||
|
||
namespace AstroPanda.Blazor.Toolkit | ||
namespace AstroPanda.Blazor.Toolkit; | ||
|
||
public class PrintService : IPrintService, IAsyncDisposable | ||
{ | ||
public class PrintService : IPrintService, IAsyncDisposable | ||
{ | ||
private readonly Lazy<Task<IJSObjectReference>> _embedPrintServiceTask; | ||
private readonly Lazy<Task<IJSObjectReference>> _embedPrintServiceTask; | ||
|
||
public PrintService(IJSRuntime js) | ||
{ | ||
_embedPrintServiceTask = new(() => js.InvokeAsync<IJSObjectReference>("import", "./_content/AstroPanda.Blazor.Toolkit/printService.js").AsTask()); | ||
} | ||
public PrintService(IJSRuntime js) | ||
{ | ||
_embedPrintServiceTask = new(() => js.InvokeAsync<IJSObjectReference>("import", "./_content/AstroPanda.Blazor.Toolkit/printService.js").AsTask()); | ||
} | ||
|
||
public async ValueTask DisposeAsync() | ||
public async ValueTask DisposeAsync() | ||
{ | ||
if (_embedPrintServiceTask.IsValueCreated) | ||
{ | ||
if (_embedPrintServiceTask.IsValueCreated) | ||
{ | ||
var module = await _embedPrintServiceTask.Value; | ||
await module.DisposeAsync(); | ||
} | ||
} | ||
var module = await _embedPrintServiceTask.Value; | ||
await module.DisposeAsync(); | ||
} | ||
} | ||
|
||
public async Task Print(string targetElementId) | ||
{ | ||
var printService = await _embedPrintServiceTask.Value; | ||
public async Task Print(string targetElementId) | ||
{ | ||
|
||
var printService = await _embedPrintServiceTask.Value; | ||
|
||
await printService.InvokeVoidAsync("print", targetElementId); | ||
} | ||
await printService.InvokeVoidAsync("print", targetElementId); | ||
} | ||
} |