Zcoil
is a model layer framework for more convenient and elegant data manipulation
Currently only Chinese documents are available
The demo uses queues to execute methods
https://channg.github.io/zcoil/demo.html
install zcoil with npm
npm i zcoil
Instantiated object
var z = new zcoil()
initialization with param
z.init({
data() {
return {
message: "hello world "
}
},
asyncGetSaySomething(param) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(param)
}, 1000)
})
},
say(param) {
this.asyncGetSaySomething(param).then((say) => {
this.message += "," + say
})
},
endToSay(){
this.message += ",come on "
}
})
Magical method call process with$coil()
var hl = z.$coil().say("Thank your star this project")
hl = hl.endToSay()
hl = hl.say("It works really well")
hl.exec((data)=>{
data.message //"hello world ,Thank your star this project,come on ,It works really well"
z.message //"hello world ,Thank your star this project,come on ,It works really well"
})
You can use the $watch
method to get the data before the $coil
method is executed
z.$watch((from,to)=>{
console.log(from.message)
console.log(to.message)
})
try it in jsfiddle