vuejs/vue-rx

[help wamted]: can't get observables via this.$observables

xyyVee opened this issue · 2 comments

"vue-rx": "^6.1.0",
"rxjs": "^6.4.0",
"vue": "^2.5.17",

in my code:
main.js

import VueRx from 'vue-rx'
Vue.use(VueRx)
import { from } from 'rxjs/operators'
data() {
    return {
        gitfs: [object, object, ...]
    }
},
subscriptions () {
    return {
      giftList$:  from(this.gifts)
    }
  },
mounted() {
    console.log(this.$observables) // get 'undefined'
}

Sorry for this question cause i'm new in vue-rx, I have tried to change from(this.gifts) to from('[1,2,3]') but still not work.

By the way I also need some advice:
My project situation to use 'vue-rx' is:
this.gifts is an array that store maybe one or more objects of different gifts like:

const gifts = [
  {
    name: 'giftA',
    num: 0, 
  },
  {
    name: 'giftB',
    num: 0
  }
]

and I want to watch the num of each single gift object until it is not change anymore like the example of wiki-search.
So i want to create several observables depend on this.gifts.length to watch the change of each num.Is there any other way to watch these only use one observable ? appreciate for all the advice!

Hey there,

I am amazed nobody answered your question in almost a month.

Have you tried using this.$watchAsObservable('gifts')?

briwa commented

@xiayuying I think it's undefined because there's an error in the console.

- import { from } from 'rxjs/operators'
+ import { from } from 'rxjs'

I think this should be the way to go (for reference). That way, the stream will be retrievable through this.$observables. Here's a little demo: https://codesandbox.io/s/vue-template-y1vig