W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2013

Re: [whatwg] [Notifications] Constructor should not have side effects

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Tue, 29 Jan 2013 00:41:41 +0200
Message-ID: <5106FEA5.4050108@helsinki.fi>
To: Elliott Sprehn <esprehn@gmail.com>, WHATWG <whatwg@whatwg.org>
On 01/29/2013 12:15 AM, Elliott Sprehn wrote:
> The Notification constructor should not have side effects. This is
> generally considered bad design, and the rest of the platform doesn't have
> this either.
>
> Specifically new Notification() should not show the notification since it
> prevents reuse of the notification after calling close(), and is surprising
> behavior.
>
> (ex. new XMLHttpRequest doesn't fire the request, new HTMLDivElement()
> shouldn't append it to the document, ...)


WebSocket, EventSource etc ctors do have "side effects".

It feels natural to me that Notification is one time object.
Once you've used it, you just create a new one if needed.

Also, it is probably too late to change Notification API.



-Olli
Received on Monday, 28 January 2013 22:42:12 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:12 GMT