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

Ian Hickson ian at hixie.ch
Tue Jan 29 12:13:00 PST 2013


On Tue, 29 Jan 2013, Ryosuke Niwa wrote:
> > 
> > It also lets you create clean abstractions and layers so one library 
> > may create the notification, but another one may eventually show it.
> 
> This seems like a valid concern. Do existing libraries do this with XHR 
> and other objects that separate primary actions from instantiations?

This is easy to do. Just return a function that creates the notification, 
instead of returning a non-shown notification object.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list