These are chat archives for ractivejs/ractive

6th
Nov 2018
kouts
@kouts
Nov 06 2018 19:22
I'm creating a plugin that all my views (i.e Ractive instances) will use, it's working great so far for patching the template something like:
function view_plugin(opts = {}) {
    return function({ instance }) {
        instance.on('config', function(){
            this.template = this.template.concat(Ractive.parse('<popupconfirmation />').t);
        });
    }
}
What's the difference if I use proto instead of instance ?
Chris Reeves
@evs-chris
Nov 06 2018 21:10
it depends on where you use the plugin
for instances they're the same
instance for extend should be the component constructor, and proto is the component prototype
Ractive.use is a slightly different ball of wax, but you can detect it by checking instance === Ractive, I think
kouts
@kouts
Nov 06 2018 22:02
I'm using it when I'm creating instances const r = new Ractive({... use: [view_plugin()]})
so in my case it's essentially the same right?
Chris Reeves
@evs-chris
Nov 06 2018 22:06
it is
kouts
@kouts
Nov 06 2018 22:09
thanks @evs-chris