Fix a couple of typing issues

- errors thrown by an observable are of `any` kind
- make a few fields readonly
This commit is contained in:
Mattias Granlund 2024-03-27 21:54:22 +01:00
parent c22a29e432
commit 3ab3c9cb1f
2 changed files with 6 additions and 6 deletions

View File

@ -21,7 +21,7 @@ export function storeToObservable<T>(svelteStore: Writable<T> | Readable<T>): Ob
*/
export function observableToStore<T>(
observable: Observable<T>
): [Readable<T | undefined>, Readable<string | undefined>] {
): [Readable<T | undefined>, Readable<any | undefined>] {
const error = writable<any>();
const store = writable<T | undefined>(undefined, () => {
// This runs when the store is first subscribed to

View File

@ -10,10 +10,10 @@ import { BehaviorSubject, Observable, Subject, distinct, map, merge, shareReplay
import type { Readable } from 'svelte/motion';
export class UserService {
readonly reset$ = new Subject<User | undefined>();
readonly loading$ = new BehaviorSubject(false);
private reset$ = new Subject<User | undefined>();
private loading$ = new BehaviorSubject(false);
readonly user$ = merge(
private user$ = merge(
new Observable<User | undefined>((subscriber) => {
invoke<User | undefined>('get_user').then((userData) => {
if (userData) {
@ -32,8 +32,8 @@ export class UserService {
distinct()
);
user: Readable<User | undefined>;
error: Readable<string | undefined>;
readonly user: Readable<User | undefined>;
readonly error: Readable<string | undefined>;
constructor(private cloud: CloudClient) {
[this.user, this.error] = observableToStore(this.user$);