Reim
Github
2.0.0
2.0.0
  • Reim.js
  • Introduction
    • Motivation
    • Concepts
  • Guide
    • Store
    • setState
    • Subscribe
    • Plugin
    • Event Emitter
    • Use with React / Preact
    • Use with Vue
    • Use with Angular / Rxjs
  • Ecosystem
    • react-reim
    • reim-task
    • reim-reporter
    • reim-persist
    • Release Notes
Powered by GitBook
On this page
  1. Guide

Use with Vue

Immutability

Unlike React, Vue relies on reactivity system so you cannot use immutable system.

Therefore you can use commit method to mutate the state directly

<template>
    <div>
        <button @click="toggleVisiblity">{{state.visibility}}</button>
    </div>
</template>

<script>
import reim from 'reim'

const toggles = reim({visibility: 'closed'})

export default {
  data: () => toggles.state,
  methods: {
    toggleVisibility() {
      toggles.commit(state => {
        state.visibility = state.visibility === 'closed' ? 'opened' : 'closed'
      })
    }
  }
}
</script>
PreviousUse with React / PreactNextUse with Angular / Rxjs

Last updated 5 years ago