1.1.6 • Published 2 years ago

vue-reset-data v1.1.6

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

vue-reset-data

A mixin to reset your data to some point of time for VueJS components

Install

NPM:

npm i --save vue-reset-data

Usage instructions

Install the mixin globally

import Resetter from 'vue-reset-data';

Vue.use(Resetter);

Or import it as an individual mixin on your component

import {ResetterMixin} from 'vue-reset-data';

export default {
  ...
  mixins: [ResetterMixin],
  ...
}

How to use it

  1. Call thefunction initResetPlugin to init the mixin at any point of the lifecycle of your component (Preferably on created or mounted):
export default {
  created() {
    this.initResetPlugin()
  }
}
  1. When you want to reset some, call the function resetData:
export default {
  methods: {
    yourMethod() {
      this.resetData([keys]);
    }
  }
}
  • keys: Arrays of strings containing the names of the data key you want to reset or a simple string with the name of the key to reset. If this value is null, will reset the whole data.

This mixin include a method named $clone to clone in deep objects. Use as follow:

export default {
  methods: {
    yourMethod() {
      const clonedObject = this.$clone(objectToClone);
    }
  }
}

NOTE: Do not use the key $originalData as part of your data.

License

MIT

1.1.6

2 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.1

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago