How can i use useObservable to create a subject #49
-
Hi! I'm currently learning RxJs and using it with react.
I was wondering how i can use the above to create a subject? I wanted to do it while staying in react. Do i have to create a separate subject resource thats outside of react? thanks for the wonderful library |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Yes you can! "Do whatever you want with Observables" is one of the main features of observable-hooks. If you want to create Subject from dependencies, you can do this: const flag$ = useObservable(
inputs$ => inputs$.pipe(
map(([flag]) => flag),
share()
),
[props.flag]
) Or if you just want to create a Subject out of thin air, you can do this: const subject$ = useObservable(() => new Subject()) |
Beta Was this translation helpful? Give feedback.
Yes you can! "Do whatever you want with Observables" is one of the main features of observable-hooks.
If you want to create Subject from dependencies, you can do this:
Or if you just want to create a Subject out of thin air, you can do this: