Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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