tstore-vue3ts

1.0.15 • Public • Published

tstore-vue3ts

demo

NPM install

npm i tstore-vue3ts

Use

import { TObject, importState } from '../TStore.plugin';
import TStore from '../TStore.plugin';

//interface.ts
//1. declare my module
interface IAge {
    myAge: number;
    newyear(): void;
}

interface ICount {
    myCount: number
    add(n: number): void;
}

//2. declare type state
export type MyState = { age: IAge } & { count: ICount } & TObject;


///3. file data store
export const count: ICount = {
    myCount: 1,
    add(n: number) {
        this.myCount += n;
    }
}

//import one data to state.
//importState({ count });

export const age: IAge = {
    myAge: 1,
    newyear() {
        this.myAge++;
    }
};

//import one data to state.
//importState({ age });

//4. import mutil data to state.
importState({ age }, { count });


/// store.ts
export function useAppStore(): MyState {
    return mystate.useTStore();
}
const mystate = new TStore<MyState>();
export default mystate;

//5. use in component
const store = useAppStore();
store.age.myAge++
store.age.newyear()

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Lints and fixes files

npm run lint

Customize configuration

See Configuration Reference.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.150latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.150
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30

Package Sidebar

Install

npm i tstore-vue3ts

Weekly Downloads

0

Version

1.0.15

License

ISC

Unpacked Size

3.72 kB

Total Files

3

Last publish

Collaborators

  • tiephoang.dev