Awesome Open Source
Awesome Open Source
Sponsorship

zcoil

Travis Status npm license

Zcoil is a model layer framework for more convenient and elegant data manipulation

document

Currently only Chinese documents are available

中文文档

Let's start with the demo

The demo uses queues to execute methods

https://channg.github.io/zcoil/demo.html

use

install zcoil with npm

npm i zcoil

easy to use in Hello world

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)
})

test it online

try it in jsfiddle


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
typescript (9,451
es6 (507
mvvm (301
promise (194
model (105
callback (39

Find Open Source By Browsing 7,000 Topics Across 59 Categories