Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This package provides Blazor applications with access to the browser's [Geolocat
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSingleton<LocationService>();
services.AddScoped<LocationService>();
...
}
```
Expand All @@ -33,14 +33,24 @@ This package provides Blazor applications with access to the browser's [Geolocat
Accuracy: @location?.Accuracy <br />
</div>

@functions
{
Location location;

protected override async Task OnInitAsync()
{
location = await LocationService.GetLocationAsync();
}
@functions
{
Location location = null;

protected async Task GetLocation()
{
location = await LocationService.GetLocationAsync();
this.StateHasChanged();
}

protected override async Task OnAfterRenderAsync(bool first)
{
if (first)
{
base.OnAfterRender(first);
await GetLocation();
}
}
}
```

Expand Down