Closed Bug 655342 Opened 14 years ago Closed 13 years ago

timer API is awkward

Categories

(Add-on SDK Graveyard :: General, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: dietrich, Assigned: erikvvold)

Details

Attachments

(1 file)

1. the APIs should return timer objects that have a cancel method, instead of ids. 2. the module should have one cancel method accepts both timer types, instead of separate "clear" methods for each timer type. actually, fixing #1 might remove the need for #2 altogether, making things yet simpler.
Seems reasonable, as long as we can implement this in a way that doesn't break backward-compatibility.
OS: Mac OS X → All
Priority: -- → P2
Hardware: x86 → All
Target Milestone: --- → Future
Whiteboard: [milestone:1.4]
Target Milestone: Future → 1.4
(Pushing all open bugs to the --- milestone for the new triage system)
Target Milestone: 1.4 → ---
Assignee: nobody → erikvvold
Pointer to Github pull-request
Attachment #579243 - Flags: review?(myk)
(In reply to Dietrich Ayala (:dietrich) from comment #0) > 1. the APIs should return timer objects that have a cancel method, instead > of ids. > > 2. the module should have one cancel method accepts both timer types, > instead of separate "clear" methods for each timer type. > > actually, fixing #1 might remove the need for #2 altogether, making things > yet simpler. Do you still think this is necessary ? Timers behave as they do on the web today, I don't think there is a value in introducing new API for doing something that is already a well known. If you need cancel it's easy: let cancel = timer.clearTimeout.bind(null, timer.setTimout(function() {}, 0, arg));
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] from comment #4) > (In reply to Dietrich Ayala (:dietrich) from comment #0) > > 1. the APIs should return timer objects that have a cancel method, instead > > of ids. > > > > 2. the module should have one cancel method accepts both timer types, > > instead of separate "clear" methods for each timer type. > > > > actually, fixing #1 might remove the need for #2 altogether, making things > > yet simpler. > > Do you still think this is necessary ? Timers behave as they do on the web > today, I don't think there is a value in introducing new API for doing > something that is already a well known. If you need cancel it's easy: > > let cancel = timer.clearTimeout.bind(null, timer.setTimout(function() {}, > 0, arg)); It isn't obvious that this would work with IDs returned from setInterval.
Status: NEW → ASSIGNED
Comment on attachment 579243 [details] Pointer to Github pull request: https://github.com/mozilla/addon-sdk/pull/288 I'll defer to Irakli on this one.
Attachment #579243 - Flags: review?(myk) → review?(rFobic)
i don't remember what code i was writing when i filed this, but it was cumbersome enough for me to file a bug. i guess if the aim is to mimic web apis and stick to that, then no we don't need this. what are the differences between this and the web timer api? if there are additive ways to not have to track the ids, that'd be nice to have.
Comment on attachment 579243 [details] Pointer to Github pull request: https://github.com/mozilla/addon-sdk/pull/288 Sorry Erik, but I think we should stick to the standard APIs where possible to keep a learning curve minimal. In addition timer id's can be passed across the workers that is not really possible with an objects. Finally we are at the stage where we don't want to make any API changes unless that's necessary which I don't think this is. That being said it's pretty easy to implement such an API as an utility function if desired: var timer = require('api-utils/timer'); exports.setTimeout = function setTimeout() { let id = timer.setTimeout.apply(timer, arguments); return { id: id, cancel: timer.clearTimeout.bind(null, id) }; }; ...
Attachment #579243 - Flags: review?(rFobic) → review-
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: