Skip to content

Abort watch with AbortSignal #179

Open
@jimmywarting

Description

@jimmywarting

it would be nice if navigator.geolocation.clearWatch could cancel a watch when a AbortSignal gets aborted.
one single AbortSignal can be used to cancel a hole bunch of things

Having one and only AbortSignal per page (like in a single-page-application) is nice
the abort signal can be used to cancel ongoing fetch calls to APIs that is needed to view the page and so much more.
I use one abort signal that gets created at every time the history changes and for every API call i make i include that signal.
so if the user quickly just jump trough the history to go back 3-5 pages then i can abort what is being called to the api.

if the Geolocation had the possibility to cancel itself when a map isn't needed anymore when navigating away from a page with a map, than that would be awesome!

i propose the possibility of passing it along with the options

navigator.geolocation.clearWatch(success, error, { 
  signal: AbortSignal.timeout(x) 
})

that way we don't have to manually keep track of a index, and calling clearWatch when needed. it would just cancel itself upon a abort event

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions