Closed fabiansanchez18 closed 1 year ago
I've made a workaround with this:
public async void StartListening()
{
tokenSource = new CancellationTokenSource();
cancellationToken = tokenSource.Token;
var timer = new PeriodicTimer(TimeSpan.FromSeconds(0.5));
while (await timer.WaitForNextTickAsync(cancellationToken))
{
Geolocation.GetCurrentPosition(
component: this,
onSuccessCallbackMethodName: nameof(OnPositionRecieved),
onErrorCallbackMethodName: nameof(OnPositionError),
options: _options);
}
}
I think it's not elegant but does the trick. the, to not overwhelm the view, use all of this as an injected service and keep track of Position property with ReactiveUi and only update on changes.
@all-contributors please add @fabiansanchez18 for bug
@IEvangelist
I've put up a pull request to add @fabiansanchez18! :tada:
Hi @fabiansanchez18 - I fixed this in fd7bb93be5183bbf0bca9d9a9be75a3c2b795b84
Your Nuget Package works as a charm when getting a single position, but when I try to enable the watching capabilities I get the following Exception:
System.ArgumentException: There is no tracked object with id '7'. Perhaps the DotNetObjectReference instance was already disposed. (Parameter 'dotNetObjectId') window.Module.s.printErr @ blazor.webassembly.js:1 put_char @ dotnet.6.0.8.dkwuqzgqao.js:1 write @ dotnet.6.0.8.dkwuqzgqao.js:1 write @ dotnet.6.0.8.dkwuqzgqao.js:1 doWritev @ dotnet.6.0.8.dkwuqzgqao.js:1 _fd_write @ dotnet.6.0.8.dkwuqzgqao.js:1 $func8738 @ 00971db2:0x1c9fbc $func8949 @ 00971db2:0x1daf9d $func8950 @ 00971db2:0x1db03d $func8951 @ 00971db2:0x1db083 $func3479 @ 00971db2:0xcc28c $func3478 @ 00971db2:0xcc26d $func1676 @ 00971db2:0x7369c $func1675 @ 00971db2:0x733b5 $func3015 @ 00971db2:0xbb26c $func2998 @ 00971db2:0xb9364 $func216 @ 00971db2:0x1a0cb $func167 @ 00971db2:0x12c57 $func166 @ 00971db2:0xbd70 $func2812 @ 00971db2:0xabf00 $func1616 @ 00971db2:0x6fcc1 $func1620 @ 00971db2:0x7032e $mono_wasm_invoke_method @ 00971db2:0x969c Module._mono_wasm_invoke_method @ dotnet.6.0.8.dkwuqzgqao.js:1 managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet @ managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:19 invokeDotNetFromJS @ blazor.webassembly.js:1 g @ blazor.webassembly.js:1 invokeMethod @ blazor.webassembly.js:1 onSuccess @ blazorators.geolocation.g.js:19 (anonymous) @ blazorators.geolocation.g.js:52 blazor.webassembly.js:1 at Microsoft.JSInterop.JSRuntime.GetObjectReference(Int64 dotNetObjectId) window.Module.s.printErr @ blazor.webassembly.js:1 put_char @ dotnet.6.0.8.dkwuqzgqao.js:1 write @ dotnet.6.0.8.dkwuqzgqao.js:1 write @ dotnet.6.0.8.dkwuqzgqao.js:1 doWritev @ dotnet.6.0.8.dkwuqzgqao.js:1 _fd_write @ dotnet.6.0.8.dkwuqzgqao.js:1 $func8738 @ 00971db2:0x1c9fbc $func8949 @ 00971db2:0x1daf9d $func8950 @ 00971db2:0x1db03d $func8951 @ 00971db2:0x1db083 $func3479 @ 00971db2:0xcc28c $func3478 @ 00971db2:0xcc26d $func1676 @ 00971db2:0x7369c $func1675 @ 00971db2:0x733b5 $func3015 @ 00971db2:0xbb26c $func2998 @ 00971db2:0xb9364 $func216 @ 00971db2:0x1a0cb $func167 @ 00971db2:0x12c57 $func166 @ 00971db2:0xbd70 $func2812 @ 00971db2:0xabf00 $func1616 @ 00971db2:0x6fcc1 $func1620 @ 00971db2:0x7032e $mono_wasm_invoke_method @ 00971db2:0x969c Module._mono_wasm_invoke_method @ dotnet.6.0.8.dkwuqzgqao.js:1 managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet @ managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:19 invokeDotNetFromJS @ blazor.webassembly.js:1 g @ blazor.webassembly.js:1 invokeMethod @ blazor.webassembly.js:1 onSuccess @ blazorators.geolocation.g.js:19 (anonymous) @ blazorators.geolocation.g.js:52 blazor.webassembly.js:1 at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.Invoke(JSRuntime jsRuntime, DotNetInvocationInfo& invocationInfo, String argsJson) window.Module.s.printErr @ blazor.webassembly.js:1 put_char @ dotnet.6.0.8.dkwuqzgqao.js:1 write @ dotnet.6.0.8.dkwuqzgqao.js:1 write @ dotnet.6.0.8.dkwuqzgqao.js:1 doWritev @ dotnet.6.0.8.dkwuqzgqao.js:1 _fd_write @ dotnet.6.0.8.dkwuqzgqao.js:1 $func8738 @ 00971db2:0x1c9fbc $func8949 @ 00971db2:0x1daf9d $func8950 @ 00971db2:0x1db03d $func8951 @ 00971db2:0x1db083 $func3479 @ 00971db2:0xcc28c $func3478 @ 00971db2:0xcc26d $func1676 @ 00971db2:0x7369c $func1675 @ 00971db2:0x733b5 $func3015 @ 00971db2:0xbb26c $func2998 @ 00971db2:0xb9364 $func216 @ 00971db2:0x1a0cb $func167 @ 00971db2:0x12c57 $func166 @ 00971db2:0xbd70 $func2812 @ 00971db2:0xabf00 $func1616 @ 00971db2:0x6fcc1 $func1620 @ 00971db2:0x7032e $mono_wasm_invoke_method @ 00971db2:0x969c Module._mono_wasm_invoke_method @ dotnet.6.0.8.dkwuqzgqao.js:1 managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet @ managed__Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_InvokeDotNet:19 invokeDotNetFromJS @ blazor.webassembly.js:1 g @ blazor.webassembly.js:1 invokeMethod @ blazor.webassembly.js:1 onSuccess @ blazorators.geolocation.g.js:19 (anonymous) @ blazorators.geolocation.g.js:52 blazor.webassembly.js:1 at Microsoft.AspNetCore.Components.WebAssembly.Services.DefaultWebAssemblyJSRuntime.InvokeDotNet(String assemblyName, String methodIdentifier, String dotNetObjectId, String argsJson)
There is some workaround to this issue or it needs a configuration that is not present on the repo sample? I tried to use it from a component and also from an Injected Service, getting the same error on both situatuions.