vue-rx icon indicating copy to clipboard operation
vue-rx copied to clipboard

Can we use props as observables?

Open dietergeerts opened this issue 7 years ago • 0 comments

Hi, we are currently investigating switching to Vue.js from AngularJS and I don't see a way to use props as observables. This is what we have currently (with https://github.com/cvuorinen/angular1-async-filter):

<child my-attribute="$ctrl.myAttribute$ | async : this">
</child>

and then inside the child:

{{$ctrl.myAttribute}}

(The parent also got myAttribute$ injected with an attribute from ui-router)

The thing is that myAttribute$ can change, so it could be switched out with another observable. In AngularJS, the async filter (pipe) handles this for us, but from what I can see in the docs of vue-rx, there is no way to do this?

The only thing I think would work is using $watchAsObservable('myAttribute$').pipe(switchAll()) in the parent and then use that to inject into the child, but imho this use-case should be part of this solution, because it also needs to handle cases where the observable itself is undefined etc....

Any ideas?

dietergeerts avatar Mar 20 '18 14:03 dietergeerts