Vue Reactivator

3.0.2 · active · verified Sun Apr 19

vue-reactivator is a lightweight (0.5KB minified & gzipped) Vue mixin designed to integrate arbitrary, non-reactive global state into Vue components, making it reactive. Currently in stable version 3.0.2, releases are infrequent, typically tied to minor feature enhancements, bug fixes, or breaking changes like dropping old Node.js versions. Its primary differentiation lies in providing a flexible framework for developers to create custom "implementations" that bridge external mutable state (e.g., browser viewport size, external APIs, legacy JavaScript libraries) with Vue's reactivity system. This allows components to react to changes happening outside the Vue ecosystem without complex manual watchers or event bus setups, offering a clean way to keep UI in sync with global data sources that are not inherently Vuex stores or similar dedicated state management solutions.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to use `vue-reactivator` with an external implementation (like `vue-browser-state`) to make global browser viewport dimensions reactive within a Vue component.

<template>
  <div>
    Your browser viewport dimensions are {{ size[0] }}x{{ size[1] }} pixels.
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import reactivator from 'vue-reactivator';
// For this example, 'vue-browser-state' is a common accompanying package.
// You would install it: `npm install vue-browser-state`
import { viewportSize } from 'vue-browser-state';

export default defineComponent({
  mixins: [
    reactivator({
      size: viewportSize
    })
  ],
  setup() {
    // In Composition API, this.size would be available after mixin application.
    // For Options API, it's directly available in template/methods/computed.
  }
});
</script>

view raw JSON →