Skip to content
/ vore Public

A state management library based on vue3 reactivity api with typescript support

Notifications You must be signed in to change notification settings

matpool/vore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vore

A state management library based on vue3 reactivity api with typescript support

Install

npm install vore or yarn add vore

Usage

Step1. Defind a store class

class User {
  firstName: string
  lastName: string

  get fullname() {
    if(!this.firstName && !this.lastName) {
      return ''
    }
    return this.firstName + ' ' + this.lastName
  }

  getUserInfo() {
    this.firstName = 'hello'
    this.lastName = 'world'
  }
}

Setp2. Create store

import { Store } from 'vore'
import { User } from 'user-path'

export const store = new Store({
  user: new User()
})

Step3. use store.get to access store instance

<template>
  <div>{{ userStore.fullname }}</div>
</template>

<script lang="ts" setup>
  import { onMounted } from 'vue'
  import { store } from 'store-path'
  
  const userStore = store.get('user')

  onMounted(() => {
    userStore.getUserInfo()
  })
</script>

About

A state management library based on vue3 reactivity api with typescript support

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published