Skip to content

Vue-Rx prevents passing props as initial value to data #105

@19r3ka

Description

@19r3ka

Ever since I added VueRx to my project, I noticed that I can no longer pass props as initial values to data objects like so:

data() { return { foo: this.bar } }, props: { bar: String }

The lack of VueRx documentation, i.e. cookbook recipes, guides, makes it very hard to use. I tried to pass props as initial data using Observables like so const data$ = merge(new Observable(), this.$watchAsObservable('propName')). It works but then there is no way to get back the new values from data$ once it is returned by this function and used as v-model inside the template.

<template>
    <child v-model="data$" />
</template>
<script>
    props: ['propName'],
    subscriptions() {
        const data$ = merge(new Observable(), this.$watchAsObservable('propName'))
       const foo$ = data$.pipe(map(doSomething)) <-- it will on run that doSomething function on the first emission and nothing else despite data$ value changing when monitored with Vue Devtools.

        return {...}
    }
</script>

I would have expected that data$ observable to stream data and be usable in the subscriptions function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions