A Vue 3 reactive function utility library providing domain-driven design patterns and reactive state management utilities.
npm install vue-fn@vue/reactivity for full reactive system integration
domain module for browsers, domain-server for Node.js environments
shared-domain module provides cross-tab/window state sharing via BroadcastChannel API
bindRef and bindReactive utilities for reactive data binding
@vue-fn/domain | Vue-reactive domain implementation with aggregations, plugins, and event system |
@vue-fn/domain-server | Server-side variant for Node.js environments |
@vue-fn/domain-shared | Cross-tab/window shared state using BroadcastChannel API |
@vue-fn/timer | Async utilities: createTimeout() for cancellable timeouts, createDeferred() for promises |
bash
Install the main domain module
npm install @vue-fn/domain
Install other modules as needed
npm install @vue-fn/domain-shared
npm install @vue-fn/timer
`
Quick Start
`typescript
import { createSingletonAgg } from '@vue-fn/domain';
import { ref } from 'vue';
const counter = createSingletonAgg(() => {
const count = ref(0);
return {
states: {
count,
},
commands: {
increment() {
count.value++;
},
},
};
});
// Use the aggregation
counter.api.commands.increment();
console.log(counter.api.states.count.value); // 1
``