Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] Add coditional rxjs operator: #538

Closed
endlacer opened this issue Jan 7, 2025 · 1 comment
Closed

[feature request] Add coditional rxjs operator: #538

endlacer opened this issue Jan 7, 2025 · 1 comment

Comments

@endlacer
Copy link

endlacer commented Jan 7, 2025

I would request a RXJS operator that is applied conditionally. For example:

public obs$ =
    fromEvent(document, 'someEcent').pipe(
      conditionalOperator(() => someLogic(), startWith(true)),
    )

And the operator would look kinda like this:

function conditionalOperator(predicate, pipeTrue?, pipeFalse?) {
  return function (source) {
    return source.pipe(
      mergeMap(value => iif(() => predicate(value), pipeTrue ? of(value).pipe(pipeTrue) : of(value), pipeFalse ? of(value).pipe(pipeFalse) : of (value)))
    )
  }
}

Would you be interested in such a operator? I would do a PR then.
Is the implementation as proposed adequate?

@eneajaho
Copy link
Collaborator

Hi, this is very specific and I don't think we should add this one.
Thanks for opening the issue.

@eneajaho eneajaho closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants