1.0.0-beta.2 • Published 5 years ago
@replygirl/vanity v1.0.0-beta.2
vanity
simple, reactive state management for any framework using @vue/reactivity
vanity keeps business logic simple by abstracting it away from application state management. It can be used as a lightweight global store, or paired with a state management pattern like vuex to better separate concerns.
While vanity was created with vue in mind, it works out of the box with other frameworks like svelte, react, and angular.
Installation
yarn add @replygirl/vanityUsage
// Creating a service
import { createService } from '@replygirl/vanity'
type State = {
bar: boolean | null
}
export default createService<State>({
name: 'foo',
baseState: {
bar: null
},
methods: ({ clear, commit, state }) => ({
setBar(bar: boolean) {
if (bar !== state.bar) commit({ bar })
},
reset() {
clear()
}
})
})// Consuming a service
import { watchEffect } from '@vue/reactivity'
import foo from '@/services/foo'
watchEffect(() => console.info(foo.bar)) // null
foo.setBar(true) // true
foo.reset() // nullLicense
1.0.0-beta.2
5 years ago
1.0.0-beta.1
5 years ago
1.0.0-alpha.5
5 years ago
1.0.0-alpha.4
5 years ago
1.0.0-alpha.3
5 years ago
1.0.0-alpha.2
5 years ago
1.0.0-alpha.1
5 years ago
1.0.0-alpha.0
5 years ago