tauri-apps / tauri-apps/plugins-workspace
[bug] plugin-geolocation in watchPosition
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
using the plugin-geolocation in android with solid, I had a problem with the watchPosition function, that never returns the channel id.
in the Js code I Find that thea wait in in the invoke function never ends.
```ts
async function watchPosition(options: PositionOptions, cb: (location: Position | null, error?: string) => void) {
const channel = new core.Channel();
channel.onmessage = (message) => {
if (typeof message === 'string') {
cb(null, message);
}
else{
cb(message);
}
};
await core.invoke('plugin:geolocation|watch_position', {
options,
channel
});
return channel.id;
}
```
so I """"fix It"""" just removing the await of the invoke function, and works well, but I thing the problem in the rust code.
```ts
async function watchPosition(options: PositionOptions, cb: (location: Position | null, error?: string) => void) {
const channel = new core.Channel();
channel.onmessage = (message) => {
if (typeof message === 'string') {
cb(null, message);
}
else{
cb(message);
}
};
core.invoke('plugin:geolocation|watch_position', {
options,
channel
});
return channel.id;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.