Skip to content

[bug] plugin-geolocation in watchPosition #2683

Open
@Bet4Arrio

Description

@Bet4Arrio

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.

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.

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;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions