Skip to content

How to "break" out of current pipe? #7316

Answered by voliva
nandin-borjigin asked this question in Q&A
Discussion options

You must be logged in to vote

You really can't.... pipe is just taking one observable and passing it to the next operator. So these three ways are equivalent:

source$.pipe(
  map(x => x + 1),
  map(x => x * 2)
)

source$.pipe(
  map(x => x + 1)
).pipe(
  map(x => x * 2)
)

const tmp$ = source$.pipe(
  map(x => x + 1)
)
tmp$.pipe(
  map(x => x * 2)
)

How can you tell an operator that the value should be skipped over the next few operators? Those operators are just functions that take in an observable and return a new one.

You have to imagine each observable as a standalone entity. You could just:

const isString = (x: string | number): x is string => typeof x === "string";
const isNumber = (x: string | number): x is number

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@nandin-borjigin
Comment options

@BribeFromTheHive
Comment options

@voliva
Comment options

Answer selected by nandin-borjigin
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants