Skip to content

Commit

Permalink
Merge pull request #7 from AH4/master
Browse files Browse the repository at this point in the history
Update for Blazor 0.9
  • Loading branch information
stimms authored Mar 26, 2019
2 parents 5155263 + 20cf20b commit 4972997
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyName>AspNetMonsters.Blazor.Geolocation</AssemblyName>
<RootNamespace>AspNetMonsters.Blazor.Geolocation</RootNamespace>
<Version>0.4.0.1017</Version>
<Version>0.4.0.1018-PRE</Version>

<DefaultItemExcludes>${DefaultItemExcludes};node_modules\**</DefaultItemExcludes>
</PropertyGroup>
Expand All @@ -26,8 +26,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="0.9.0-preview3-19154-02" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.9.0-preview3-19154-02" />
</ItemGroup>

</Project>
10 changes: 8 additions & 2 deletions AspNetMonsters.Blazor.Geolocation/LocationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ public class LocationService
{
static IDictionary<Guid, TaskCompletionSource<Location>> _pendingRequests = new Dictionary<Guid, TaskCompletionSource<Location>>();
static IDictionary<Guid, Action<Location>> _watches = new Dictionary<Guid, Action<Location>>();
private readonly IJSRuntime jSRuntime;

public LocationService(IJSRuntime jSRuntime)
{
this.jSRuntime = jSRuntime;
}

public async Task<Location> GetLocationAsync()
{
var tcs = new TaskCompletionSource<Location>();
var requestId = Guid.NewGuid();

_pendingRequests.Add(requestId, tcs);
var result = await JSRuntime.Current.InvokeAsync<Location>("AspNetMonsters.Blazor.Geolocation.GetLocation", requestId);
var result = await jSRuntime.InvokeAsync<Location>("AspNetMonsters.Blazor.Geolocation.GetLocation", requestId);

return await tcs.Task;
}
Expand All @@ -26,7 +32,7 @@ public async Task WatchLocation(Action<Location> watchCallback)
{
var requestId = Guid.NewGuid();
_watches.Add(requestId, watchCallback);
await JSRuntime.Current.InvokeAsync<Location>("AspNetMonsters.Blazor.Geolocation.WatchLocation", requestId);
await jSRuntime.InvokeAsync<Location>("AspNetMonsters.Blazor.Geolocation.WatchLocation", requestId);
}

[JSInvokable]
Expand Down

0 comments on commit 4972997

Please sign in to comment.