mirror of
https://github.com/koloml/philomena-tagging-assistant.git
synced 2026-09-22 20:09:39 +00:00
Merge pull request #177 from koloml/feature/test-preferences-api
Testing behavior of internal preferences class
This commit is contained in:
@@ -70,7 +70,7 @@ export default class ConfigurationController {
|
||||
return;
|
||||
}
|
||||
|
||||
callback(changes[this.#configurationName].newValue);
|
||||
callback(changes[this.#configurationName].newValue as Record<string, any>);
|
||||
}
|
||||
|
||||
this.#storage.subscribe(subscriber);
|
||||
|
||||
@@ -89,16 +89,17 @@ export type WithFields<FieldsType extends Record<string, any>> = {
|
||||
* API.
|
||||
*/
|
||||
export default abstract class CacheablePreferences<Fields> {
|
||||
#controller: ConfigurationController;
|
||||
#cachedValues: Map<keyof Fields, any> = new Map();
|
||||
#disposables: Function[] = [];
|
||||
readonly #controller: ConfigurationController;
|
||||
readonly #cachedValues: Map<keyof Fields, any> = new Map();
|
||||
readonly #disposables: Function[] = [];
|
||||
|
||||
/**
|
||||
* @param settingsNamespace Name of the field inside the extension storage where these preferences stored.
|
||||
* @param [controller] Configuration controller. If not provided, default controller will be used.
|
||||
* @protected
|
||||
*/
|
||||
protected constructor(settingsNamespace: string) {
|
||||
this.#controller = new ConfigurationController(settingsNamespace);
|
||||
protected constructor(settingsNamespace: string, controller: ConfigurationController = new ConfigurationController(settingsNamespace)) {
|
||||
this.#controller = controller;
|
||||
|
||||
this.#disposables.push(
|
||||
this.#controller.subscribeToChanges(settings => {
|
||||
|
||||
Reference in New Issue
Block a user