Closed fy0 closed 2 years ago
well, use Observer
component instantly can works:
store.ts:
class A {
@observable
test: number[] = []
constructor() {
makeObservable(this)
}
@action
addTest() {
this.test.push(1)
}
}
export const s = new A()
test.vue:
<template>
<observer>
{{ state.test }}
</observer>
</template>
<script lang="ts" setup>
import { s } from '../store'
import { Observer } from 'mobx-vue-lite'
onBeforeMount(async () => {
setInterval(() => {
console.log('fetch log')
s.addTest()
}, 5000) as any
})
</script>
@wobsoriano Any suggestion ?
Should be working now. Please update. Need to make the return value of useLocalObservable
to a non-readonly
I tried use mobx-vue-lite in a project, this is my code:
In vue component:
It seems not work at all. Am i did a wrong step?