omi/packages/omiv
dntzhang 4499f0d967 publish: omiv v0.1.4 2019-10-03 10:55:03 +08:00
..
config publish: omiv 0.1.3 2019-10-03 10:40:11 +08:00
dist publish: omiv v0.1.4 2019-10-03 10:55:03 +08:00
src publish: omiv v0.1.2, remove vue and vuex 2019-10-03 10:33:07 +08:00
README.md publish: omiv v0.1.4 2019-10-03 10:55:03 +08:00
package.json publish: omiv v0.1.4 2019-10-03 10:55:03 +08:00

README.md

Omiv

Observable store system for Vue apps.

Usage

import { $ } from 'omiv'
import HelloWorld from './components/HelloWorld.vue'

export default $({
  name: 'app',
  components: {
    HelloWorld
  },
  store: new class {
    data = {
      count: 1
    };
    sub = () => {
      this.data.count--
    };
    add = () => {
      this.data.count++
    }
  }
})

HelloWrold.vue:

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <button @click="store.sub">-</button>
    <span>{{state.count}}</span>
    <button @click="store.add">+</button>
  </div>
</template>

<script>
import { $ } from 'omiv'
export default $({
  name: 'HelloWorld',
  props: {
    msg: String
  },
  useSelf: ['count']
  //or, use will update all the children components 
  //use: ['count']
})
</script>

Differences to Vuex

Vuex:

data.items[1] = 'x' // is NOT reactive
data.items.length = 2 // is NOT reactive

Omiv:

data.items[1] = 'x' // is reactive
data.items.size(2)  // is reactive

License

MIT © Tencent