This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Magix.State介绍 #39
Comments
事件changed
let Magix = require('magix');
module.exports = Magix.View.extend({
init() {
Magix.State.on('changed', function(e) {
console.log(e.type, e.keys); //keys是哪些有变化的key集合对象
});
},
render() {
console.log('view render');
}
}); |
Closed
代码没同步更新上去 |
拆分set方法
Magix.State.set方法
let Magix = require('magix');
module.exports = Magix.View.extend({
init() {
this.observeState('abc,def');
},
render() {
console.log('view render');
},
'test<click>' () {
Magix.State.set({
abc: Math.random();
});
Magix.State.set({
def: Math.random();
});
}
}); 可以通过 Magix.State.digest方法
let Magix = require('magix');
module.exports = Magix.View.extend({
init() {
this.observeState('abc,def');
},
render() {
console.log('view render');
},
'test<click>' () {
Magix.State.set({
abc: Math.random();
});
Magix.State.set({
def: Math.random();
});
Magix.State.digest();//多次设置,统一派发事件
// 如果即设置数据又派发事件,可以与Magix.Updater一样简写为
Magix.State.digest({
def: Math.random();
});
}
}); |
@gmfenglin 代码未动,文档先行 |
Closed
dist 目录下的cmd 版本view 的share和getShare方法没有了,用什么代替? |
tmpl 目录下的view 存在share和getShare方法. |
@gmfenglin https://github.com/thx/magix/blob/master/tool/gulpfile.js#L11 克隆下来,修改打包工具 目前设计了 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Magix.State
API
view.observeState
Magix.State.get
Magix.State.set
Magix.State.has
The text was updated successfully, but these errors were encountered: