@ianwalter/vue-component-reset

3.0.1 • Public • Published

@ianwalter/vue-component-reset

A Vue.js component mixin that makes restoring initial state to the component simple

npm page

Installation

yarn add @ianwalter/vue-component-reset

Usage

import vueComponentReset from '@ianwalter/vue-component-reset'

const resetMixin = vueComponentReset(() => ({ msg: 'Hello', count: 0 }))

export default {
  mixins: [resetMixin],
  methods: {
    someAction () {
      this.reset() // Reset data to it's initial state.
      this.reset('msg') // Reset msg to it's initial state.
    }
  }
}

Related

  • vuex-reset - A Vuex plugin that makes restoring initial state to the store simple

License

Apache 2.0 with Commons Clause - See LICENSE

 

Created by Ian Walter

Package Sidebar

Install

npm i @ianwalter/vue-component-reset

Weekly Downloads

12

Version

3.0.1

License

SEE LICENSE IN LICENSE

Unpacked Size

4.76 kB

Total Files

7

Last publish

Collaborators

  • ianwalter