mobxjs / mobx-vue-lite

Lightweight Vue 3 bindings for MobX based on Composition API.
MIT License
69 stars 3 forks source link

vue3 and composition api support is here ! #1

Open iChenLei opened 2 years ago

iChenLei commented 2 years ago

https://github.com/mobxjs/mobx-vue/issues/60 [RFC] mobx-vue v3

I decided add vue3 support via mobx-vue-lite after consideration. mobx-vue current only support vue2 and mobx( v6 >= 2.1.* , v2|v3|v4|v5 < 2.1.0). @wobsoriano , Robert Soriano Thanks for youre great work for vue3 support, now you are mobxjs/mobx-vue-lite project's maintainer , continue your great work please. 🚀

wobsoriano commented 2 years ago

Thank you! Happy to be here.

So I imported the files from https://github.com/wobsoriano/mobx-vue-lite. Should we publish a new package?

iChenLei commented 2 years ago

No, mobx-vue-lite is ok. mobx-vue support vue2 and mobx-vue-lite support vue3. We don't need publish another new package. Please @ me if you need any help, thanks. ( Hope i am not misunderstanding your meaning

wobsoriano commented 2 years ago

Okay. All good, thanks!

EverSeenTOTOTO commented 2 years ago

Very greate efforts! Thanks for everyone here. Really, I believe the future of state management in frontend is Simple Functional Component + Well Designed Domain Models (and the models, stores, services are driven by libs like mobx.

import { useState } from "react"
import { observer, useLocalObservable } from "mobx-react-lite"

export default observer(() => {
    const state = useLocalObservable(() => ({
      count: 0,
      get double() {
        return this.count * 2
      },
      increment() {
        this.count++
      }
    }))

    //...
})
import { defineComponent } from 'vue'
import { useLocalObservable } from 'mobx-vue-lite'

export default defineComponent({
    setup() {
        const state = useLocalObservable(() => ({
            count: 0,
            get double() {
                return this.count * 2
            },
            increment() {
                this.count++
            }
        }))

        return { state }
    }
})
MeetzhDing commented 1 week ago

No, mobx-vue-lite is ok. mobx-vue support vue2 and mobx-vue-lite support vue3. We don't need publish another new package. Please @ me if you need any help, thanks. ( Hope i am not misunderstanding your meaning

@iChenLei

Could this libaray work with vue2.6 and composition-api@1.7.0 ?

The SourceCode seems to be very simple, but the import code maybe need be modified ?


Update: mobx-vue should can work with vue2.6 + @vue/composition-api according my analysis. I will update my conclusion after practice.