-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Svelte supports rxjs observables but it is not reflected in types #8726
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
Comments
This is an implementation detail for rxjs interop, but I'm not sure we want to expose it publicly. If you have a rxjs observable, why would you want to use it with |
I want to mix svelte stores with rx observables |
Your request is legit, however the severity is so over-stated. I can easily fix it with |
I've taken to using these two helpers in order to get interop: export function store_to_observable<T>(store: Writable<T> | Readable<T>): Observable<T> {
return new Observable<T>((observer) => {
return store.subscribe((value) => observer.next(value));
});
}
export function observable_to_store<T>(observable: Observable<T>): Readable<T> {
const store = Readable<T>();
observable.subscribe((value) => store.set(value));
return store;
} But it sound to me like doing this is perfectly safe: export function observable_to_store<T>(observable: Observable<T>): Readable<T> {
return observable as any as Readable<T>;
} Is this correct? |
observable as unknown as Readable<T>; It's useful anyway |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
I cannot use an
rxjs.Observable
withderived
because svelte'sUnsubscriber
is not typed properly:svelte/src/runtime/store/index.ts
Lines 6 to 7 in 3bc791b
It should be typed as
Reproduction
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: