question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `set` alias for `next` on `BehaviorSubject`

See original GitHub issue

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 as set on BehaviorSubject. (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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

19reactions
benleshcommented, May 8, 2019

So after discussion with the core team. It seems more reasonable to create a separate package with a SvelteSubject that would behave in the way you want… it is exactly this:

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)

3reactions
spieralacommented, Mar 7, 2021

Started a small project with the “SvelteSubject” and implemented the svelte stores as RxJS Observables: https://github.com/spierala/svelte-store-rxjs

  • writable() returns a Writable instance. Writable extends RxJS BehaviorSubject.
  • readable() and derived() return a RxJS Observable
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I subscribe to a BehaviorSubject from another ...
From your psuedo-code it looks like you are already subscribing to the BehaviorSubject from Service A in Service B. If you want to...
Read more >
BehaviorSubject - RxJS Reference - InDepth.Dev
BehaviorSubject is a variant of a Subject which has a notion of the current value that it stores and emits to all new...
Read more >
slingjs - npm
Sling is a client-side JavaScript framework for building Single Page Applications (SPAs). Sling is lightweight, 23KB minified, and less than 7KB gzipped. Sling ......
Read more >
Overview - ReactiveX
There are also a few specializations of the Subject type: BehaviorSubject , ReplaySubject , and AsyncSubject . Multicasted Observables. A "multicasted ...
Read more >
Handling Observables with NgIf and the Async Pipe
Get 73% off the Angular Master Bundle! See the bundle then add to cart and your discount is applied. 1 days. 07 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found