-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add set
alias for next
on BehaviorSubject
#4740
Comments
dumb q: why svelte can't use at a first sight, I'm bit on opposite path for similar reason to we discussed around zone.js 1. I don't want to some framework specific path (even though this is only setting alias) 2. we tend to block / remove alias as much as it's generally bring confusion from consumer point of view. |
Here's a little playground with https://svelte.dev/repl?version=3.1.0&gist=90c5eb4c3e9754ebafb1ed0f828866a2 |
...and a very slightly modified version illustrating assignments directly to a BehaviourSubject: https://svelte.dev/repl?version=3.1.0&gist=542cdd9735cb7964a5c618374178a5c2 |
This would be extremely helpful in Angular too. [(value)]="fooBehaviorSubject.value" |
🤷♂ |
So after discussion with the core team. It seems more reasonable to create a separate package with a class SvelteSubject extends BehaviorSubject {
set(value) {
super.next(value);
}
lift(operator) {
const result = new SvelteSubject();
result.operator = operator;
result.source = this;
return result;
}
} @Rich-Harris what do you think about us adding this to the svelte org? (I'd happily help maintain that for you) |
I've been looking into using rxjs with svelte today but didn't find much info apart this issue and sveltejs/svelte#2549 Is there some documentation yet, or maybe tests with some code examples? |
Hey, sorry — just seeing this. Sure, would be glad to host it in the Svelte org, thank you. |
Hi @benlesh. As i can see from the discussion this issue can be closed. |
Started a small project with the "SvelteSubject" and implemented the svelte stores as RxJS Observables:
|
@benlesh thank you for this! I have two questions if you ever come back to this thread and have some time:
Side Note: I wrote my first npm package with a handful of rxjs-based svelte actions for ppl who don't want to touch the rxjs side of things, but also expose an |
The lift method would be optional, honestly. |
What did the name of this package end up being? I'm not finding it. |
@DallasHoff The package @AlexWarnes wrote and maintains is svelte-fuse-rx. I don't think there's official support for RxJS inside Svelte yet. |
Per this discussion on Twitter
Basically, svelte has amazing support for RxJS. Particularly in reading from RxJS observables.
This very small addition to RxJS would enable Svelte users to very conveniently trigger reactive updates through RxJS.
Proposal
Just alias
next
asset
onBehaviorSubject
. (I don't see a reason yet to add it to all subjects).That would enable Svelte users to simply bind to them in their templates.
cc/ @Rich-Harris
Other things
It's probably worth discussion with Svelte experts if this solves a big enough use case for them to be a valid change, and/or what other use cases we might need to consider.
The text was updated successfully, but these errors were encountered: