vue2-deepob

1.1.1 • Public • Published

vue2-deepob

Deep observable for Vue 2.x , advance experience Vue3 Observeable .

Note

not support IE11

example

https://github.com/leozale/vue2-deepob/tree/master/example

Install

import Vue from "vue";
import DeepOB from "vue2-deepob";
Vue.use(DeepOB);

Demo

<template>
  <div>{{ user.name }}</div>
  <button @click="user.changeName()"></button>
  <button @click="user.addOtherName()"></button>
   <div>  {{user.otherName}}  <button @click="user.deleteOtherName()"> delete </button> </div>
</template>

<script>

  class User{

      constructor(){
          this.name = "default name";
          // no otherName property!!!
      }

      changeName(){
          this.name = 'testname-'+Date.now();
      }

      addOtherName(){
          this.otherName = "otherName!!!";
      }

      deleteOtherName(){
          delete this.otherName; //  no need Vue.delete !
      }
  }


  new Vue({
      data(){
          return {
              user:this.$deepob(new User())
          }
      }
  })
</script>

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i vue2-deepob

Weekly Downloads

4

Version

1.1.1

License

ISC

Unpacked Size

5.27 kB

Total Files

6

Last publish

Collaborators

  • leozale