riot.js global mixin


trigger は長いのでemitに変更してみる。

riot.mixin({emit:function(){return this.trigger.apply(this,Array.from(arguments)) } });

確認

<script src="//gnjo.github.io/riot.js"></script>
<t></t>
<t2></t2>
riot.mixin({emit:function(){return this.trigger.apply(this,Array.from(arguments)) } })
;
riot.tag('t',false,function(opts){
 this.on('xyzed',(x)=>{console.log('xyzed',x)})
 this.emit('xyzed','emit');
 this.trigger('xyzed','trigger')
});
riot.tag('t2',false,function(opts){
 this.on('xyzed',(x)=>{console.log('xyzed',x)})
 this.emit('xyzed','t2 emit');
 this.trigger('xyzed','t2 trigger')
});
riot.mount('*')