- From: Mounir Lamouri <mounir@lamouri.fr>
- Date: Wed, 15 May 2013 14:44:45 +0100
- To: public-script-coord@w3.org
On 09/05/13 21:42, Christophe Dumez - SISA wrote: > Hi, > > I commented on that bug. If I remember correctly, clear() was added for consistency with the Contact API. > It is merely a convenience function so I don't have strong feeling either way. > > However, I do think that clear() is a lot more readable than getPendingAlarms().then(alarms=>alarms.forEach(x=>x.cancel())); .clear() has a performance advantage compared to .getPendingAlarms().then(alarms=>alarms.forEach(x=>x.cancel())): when you use .clear() there will be only one DB access that will remove every alarm that belongs to the caller. Using .cancel() for each alarm might do as much calls to the DB which is going to be significantly slower. It is possible to argue that a clever implementation could delay the DB access so it can perform multiple operations at the same time but I think having a .clear() method is a syntax sugar that could make life easier for developers and implementations and it is worth taking. -- Mounir
Received on Wednesday, 15 May 2013 13:45:22 UTC