Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

ianwalter/vue-component-reset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@ianwalter/vue-component-reset

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

npm page CI

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

Hippocratic License - See LICENSE

 

Created by Ian Walter