Re: aborting getCurrentPosition()?

On Wed, May 6, 2009 at 1:52 PM, Max Froumentin <maxfro@opera.com> wrote:
> Hi Andrei,
>
> Andrei Popescu <andreip@google.com> writes:
>
>> Hi Max,
>>
>> On Wed, May 6, 2009 at 8:48 AM, Max Froumentin <maxfro@opera.com> wrote:
>>> Hi,
>>>
>>> Was the possibility of aborting an asynchronous operation ever considered?
>>> Either through abort(), a la XMLHttpRequest:
>>>
>>> var asyncOperation =  navigator.geolocation.getCurrentPosition(successCallback,  errorCallback, {maximumAge:600000});
>>> // Waiting for success or callback, GPS Fix is taking time, user gets bored
>>>
>>
>> Hmm, what is the exact motivation for this? If the user gets bored,
>> you can just provide some 'cancel' button and set a flag so that when
>> you eventually get the callback (either success or error) you don't
>> react to it.
>
> With an abort mechanism the callback would never be called after you've cancelled, whereas with the solution you suggest it could happen a while later, and could possibly interfere with subsequent calls to getCurrentPosition. And also, interrupting the GPS would save CPU cycles that would be wasted otherwise
>


Yes, I see. I don't have much against it, even though I'd prefer the
API to stay as simple as possible. Would you be ok with discussing the
cancel() function in the scope of the v2 of the Geolocation API?

Anyway, if we go down this route, my proposal would be to make
getCurrentPosition() return an identifier (just like watchPosition())
and rename clearWatch() to 'clearRequest' (or similar) so that it can
clear either type of request.

Thanks,
Andrei

Received on Wednesday, 6 May 2009 14:24:06 UTC