Loader vs ES6 Classes

Axel Rauschmayer axel at rauschma.de
Mon Aug 4 06:29:19 PDT 2014


On Aug 4, 2014, at 15:16 , Juan Ignacio Dopazo <jdopazo at yahoo-inc.com> wrote:

> In practice we've found that we rarely use the "new Loader(hooks)` option and instead this is more common:
> 
> var loader = new Loader();
> var loaderFetch = loader.fetch.bind(loader);
> 
> loader.fetch = function (loadRecord) {
>   // do something
>   return loaderFetch(loadRecord);
> };



Why not like this then? You’d need (a compiler for) ES6, though.

```js
class MyLoader extends Loader {
    fetch(loadRecord) {
        // do something
        return super(loadRecord);
    }
}
let loader = new MyLoader();
```

-- 
Dr. Axel Rauschmayer
axel at rauschma.de
rauschma.de



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140804/931fff1f/attachment-0001.html>


More information about the es-discuss mailing list