Re: [service_worker] Notification constructor

On Tue, Jun 16, 2015 at 12:28 AM, Conrad Irwin <conrad.irwin@gmail.com> wrote:
> I've been implementing some things with service workers, and it's a little
> bit frustrating to have to use
>
>   self.registration.showNotification("hi!")
>
> instead of the more normal:
>
>   new Notification("hi!")
>
> Is there a technical reason that service workers can't call the Notification
> constructor as usual?

I recommend reading through this thread:

  https://lists.w3.org/Archives/Public/public-whatwg-archive/2014Sep/thread.html#msg60
  https://lists.w3.org/Archives/Public/public-whatwg-archive/2014Oct/thread.html#msg9


> It would be nice for two reasons:
>
> 1. I could use the same wrapper library in-page and in-worker,

If you already have a wrapper library, you could wrap both.


> 2. I'd be able to call .close() on the returned Notification.

There is nothing that prevents that. Though currently you'd need to
get hold of the Notification object through the getNotifications()
method. Perhaps we should also resolve the promise returned by
showNotification() with a Notification object. You might want to file
an issue against the specification for that.


-- 
https://annevankesteren.nl/

Received on Tuesday, 16 June 2015 05:15:23 UTC