Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ktsn/sinai
Class based state management for Vue
https://github.com/ktsn/sinai
Last synced: about 2 months ago
JSON representation
Class based state management for Vue
- Host: GitHub
- URL: https://github.com/ktsn/sinai
- Owner: ktsn
- License: mit
- Created: 2017-01-27T00:59:02.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-12-28T01:14:29.000Z (9 months ago)
- Last Synced: 2024-07-01T00:22:45.456Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.23 MB
- Stars: 111
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Sinai
Class based state management for Vue.
## Examples
```ts
import { defineStore } from 'sinai'// Declare a store with class syntax
class CounterState {
// Properties will be reactive value
count = 0// Getters will be computed property
get half(): number {
return this.count / 2
}inc(): void {
this.count += 1
}dec(): void {
this.count -= 1
}
}// Create composable with defineStore function
export const useCounter = defineStore(CounterState)
``````ts
import { createApp } from 'vue'
import { createSinai } from '../src'
import App from './components/App.vue'// Create Sinai instance
const sinai = createSinai()// Install Sinai instance to Vue app
createApp(App).use(sinai).mount('#app')
``````vue
import { useCounter } from '../store/counter'
const counter = useCounter()
-
{{ counter.count }}
+```
For other examples, see [tests](test/specs/).
## License
MIT