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

[ General question ] functional API, RxJS-like #220

Open
TheCelavi opened this issue Jan 11, 2024 · 2 comments
Open

[ General question ] functional API, RxJS-like #220

TheCelavi opened this issue Jan 11, 2024 · 2 comments

Comments

@TheCelavi
Copy link

Hello,

I was just wondering if you ever considered to provide RxJS-like API? Something like:

use function Rx\from;
use function Rx\op1;
use function Rx\op2;

from(1)
    ->pipe(
        op1(),
        op2(),
        ...
    )
    ->subscribe();

Thank you!

@davidwdan
Copy link
Member

In JS, the main reason they switched to pipe was for tree-shaking, which isn't necessary in PHP. Is there something that you're trying to do that can't be done with the current API?

@TheCelavi
Copy link
Author

No, not that I have stumbled upon. The reason why I was asking this was purely DX, my first interaction with ReactiveX starts with RxJS. Like, I had this example:

$obs1->withLatestFrom([$obs2, $obs3,....])

which in RxJS would look like:

withLatestFrom([
$obs1,
$obs2,
$obs3,
...
])

Clearly, there is no any kind of value in terms of "functionality" - both examples would produce same result. There is only one value in supporting second example as well is that it would make life much easier for us coming from RxJS with already developed mental model when working with ReactiveX.

Now, question is -> would RxPHP be interested in providing such "syntactic suggar" within this library as well?

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