This commit is contained in:
syuilo 2017-02-18 16:42:41 +09:00
parent 9e6108f3e2
commit f9058cb739
3 changed files with 21 additions and 14 deletions

View File

@ -3,7 +3,7 @@ riot = require \riot
module.exports = (me) ~>
i = if me? then me.token else null
(require './scripts/i.ls') me
(require './scripts/i') me
riot.mixin \api do
api: (require './scripts/api').bind null i

View File

@ -0,0 +1,20 @@
const riot = require('riot');
module.exports = me => {
riot.mixin('i', {
init: () => {
this.I = me;
this.SIGNIN = me != null;
if (this.SIGNIN) {
this.on('mount', () => {
me.on('updated', this.update);
});
this.on('unmount', () => {
me.off('updated', this.update);
});
}
},
me: me
});
};

View File

@ -1,13 +0,0 @@
riot = require \riot
module.exports = (me) ->
riot.mixin \i do
init: ->
@I = me
@SIGNIN = me?
if @SIGNIN
@on \mount ~> me.on \updated @update
@on \unmount ~> me.off \updated @update
me: me