wire-vue
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Wire Vue

Utility library for Vue that helps get reactive data from Wire data-container layer by providing special component <WireData />

How to

  1. Dependency:
npm i -D wire-vue cores.wire
or 
yarn add -D wire-vue cores.wire
  1. Vue plugin:
import { createApp } from 'vue';
import WireVue from 'cores.wire-vue';
import App from './App.vue';

createApp(App)
  .use(WireVue) 
  .mount('#app');
  1. Use: (simple)
  <WireData
    v-slot="{ has, data }"
    :for="DataKeys.COUNT"
    :when="() => true"
  >
    <h1>{{ has ? data : 'no data' }}</h1>
  </WireData>

(with naming slots)

  <WireData :for="DataKeys.COUNT" :when="() => true">
    <template #default="{ data }">
      <h1>{{ data }}</h1>
    </template>
    <template #undefined>
      <p>Value is undefined</p>
    </template>
  </WireData>
  1. Update WireData from anywhere in the app:
const count = ref<number>(Wire.data(DataKeys.COUNT).value);
watch(count, (value: number) => Wire.data(DataKeys.COUNT, value));

Readme

Keywords

none

Package Sidebar

Install

npm i wire-vue

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

7.87 kB

Total Files

9

Last publish

Collaborators

  • vladimir.cores