vue-nonreactive

Vue.js plugin that allows you to disable reactivity on an object
5,974 58
Install
npm install vue-nonreactive
Latest Version:0.1.0
Vue:1 · 2
License:MIT
Last Updated:Jul 6, 2020
Links: GitHub  ·  npm
Maintainer: rpkilby

vue-nonreactive

Build Status codecov.io

Disable Vue reactivity for a given object. If you're using this, you may want to rethink your data model. However, this plugin is useful in a small subset of cases where you need to prevent Vue from walking nested properties that do not represent application state. eg, your model has a reference to a data store or cache.

Example:

new Vue({
    el: 'body',
    data() {
        const instance = postStore.fetch({include: ['author', 'comments.author']})
        Vue.nonreactive(instance._cache)

        return {post: instance, },
    },
    ...
});

In the above case, the object _cache does not represent pure state and should not be observed.

How this works

When Vue observes an object, it walks each attribute and converts it into a reactive property. Any nested objects are then also observed. However, Vue will skip observation if it detects that the object is already observed. We can make an object non-reactive by assigning a dummy observer, duping Vue's observer detection.

Release process

$ npm version <update type>
$ git push --follow-tags
$ npm publish

Related Packages

vue

The progressive JavaScript framework for building modern web UI.

588,019,132 54,801
vue
@vueuse/shared
372,738,348 22,398
@vueuse/core

Collection of essential Vue Composition Utilities

367,188,523 22,398
@vitejs/plugin-vue

The official plugin for Vue SFC support in Vite.

333,357,380 686
eslint-plugin-vue

Official ESLint plugin for Vue.js

266,364,830 4,591

Version History

Version Released Vue License
0.1.0 * MIT
0.0.1 ^1.0.21 MIT