1.3.5 • Published 2 years ago

vue-composition-api-proxied v1.3.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vue-composition-api-proxied

GitHub code size in bytes GitHub repo size npm npm npm npm NPM npm GitHub last commit npm collaborators

A Proxy based alternative to reactive in Vue 2 / Vue Composition API. It makes new properties reactive without the noise of Vue.set(...).

NOTE: This project is not IE-11 compatible since it uses Proxy. It's for projects stuck on Vue 2 who would like better reactivity.

Usage

Vue 2 & @vue/composition-api

import { reactive } from '@vue/composition-api';
...
setup () {
  const user = reactive({});
  user.name = 'Foo'; // Not reactive! Booo!
  return { user };
},
...

Using proxied instead

import { proxied } from 'vue-composition-api-proxied';
...
setup () {
  const user = proxied({});
  user.name = 'Foo'; // Reactive! Yay!
  return { user };
},
...

Proxy sub-elements, or opt-out

import { noProxy, proxied } from 'vue-composition-api-proxied';
...
setup () {
  const user = proxied({});
  user.billingAddress = { street: '1234 Wall St' }; // Deep-reactivity
  user.shippingAddress = noProxy({ street: '1234 Penny Lane' }); // Not proxied (e.g. not reactive)
  return { user };
},
...

See tests for details on how it works, but quick tips:

  • Works on objects and arrays
  • Also proxies sub-elements, even if they're added later
  • Currently does not proxy Map, Set, RegExp, Date, Promise (those are left as-is)
  • PRs with test coverage welcome

MIT License

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.3.2

2 years ago

1.1.4

2 years ago

1.3.1

2 years ago

1.1.3

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago