I have a store "{{ userStore.name }}". I have
{{ cartStore.items.length }} items in the cart.
</p>
+ <div>
+ <p>Counter: {{ counterStore.double }} = 2 x {{ counterStore.n }}</p>
+ <button @click="counterStore.increment(10)">Increment</button>
+ <button @click="counterStore.fail">Fail</button>
+ <button @click="counterStore.decrementToZero(300)">Countdown!</button>
+ </div>
</template>
<script setup lang="ts">
import { useUserStore } from '../stores/user'
import { useCartStore } from '../stores/cart'
+import { useCounter } from '../stores/counter'
const userStore = useUserStore()
const cartStore = useCartStore()
+const counterStore = useCounter()
</script>
// TODO: we probably need to ensure the latest version of the store is kept:
// without effectScope, multiple stores will be created and will have a
// limited lifespan for getters.
+ // add a dev only variable that is removed in unmounted and replace the store
let hasSubscribed = true
if (!registeredStores.has(store.$id)) {
registeredStores.set(store.$id, store)
componentStateTypes.push('🍍 ' + store.$id)
- hasSubscribed = true
+ hasSubscribed = false
+ console.log('registing for the first time')
}
setupDevtoolsPlugin(