Use finnish notation for observables (#2905)

To help make our usage of the observables more readable/intuitive.
This commit is contained in:
Hugh Nimmo-Smith
2024-12-17 04:01:56 +00:00
committed by GitHub
parent e4bd9d7cf9
commit 79c40f198c
30 changed files with 491 additions and 490 deletions

View File

@@ -31,17 +31,17 @@ export class Setting<T> {
}
}
this._value = new BehaviorSubject(initialValue);
this.value = this._value;
this._value$ = new BehaviorSubject(initialValue);
this.value$ = this._value$;
}
private readonly key: string;
private readonly _value: BehaviorSubject<T>;
public readonly value: Observable<T>;
private readonly _value$: BehaviorSubject<T>;
public readonly value$: Observable<T>;
public readonly setValue = (value: T): void => {
this._value.next(value);
this._value$.next(value);
localStorage.setItem(this.key, JSON.stringify(value));
};
}
@@ -50,7 +50,7 @@ export class Setting<T> {
* React hook that returns a settings's current value and a setter.
*/
export function useSetting<T>(setting: Setting<T>): [T, (value: T) => void] {
return [useObservableEagerState(setting.value), setting.setValue];
return [useObservableEagerState(setting.value$), setting.setValue];
}
// null = undecided