Skip to content

How can i use useObservable to create a subject #49

Answered by crimx
ShravanSunder asked this question in Q&A
Discussion options

You must be logged in to vote

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())

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@crimx
Comment options

@ShravanSunder
Comment options

@crimx
Comment options

@ShravanSunder
Comment options

@ShravanSunder
Comment options

Answer selected by ShravanSunder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #48 on March 23, 2021 15:51.