fix pizzax (#8099)
This commit is contained in:
parent
e159f15600
commit
1b526eb573
|
@ -10,6 +10,8 @@ type StateDef = Record<string, {
|
||||||
|
|
||||||
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never;
|
type ArrayElement<A> = A extends readonly (infer T)[] ? T : never;
|
||||||
|
|
||||||
|
const connection = $i && stream.useChannel('main');
|
||||||
|
|
||||||
export class Storage<T extends StateDef> {
|
export class Storage<T extends StateDef> {
|
||||||
public readonly key: string;
|
public readonly key: string;
|
||||||
public readonly keyForLocalStorage: string;
|
public readonly keyForLocalStorage: string;
|
||||||
|
@ -20,8 +22,6 @@ export class Storage<T extends StateDef> {
|
||||||
public readonly state: { [K in keyof T]: T[K]['default'] };
|
public readonly state: { [K in keyof T]: T[K]['default'] };
|
||||||
public readonly reactiveState: { [K in keyof T]: Ref<T[K]['default']> };
|
public readonly reactiveState: { [K in keyof T]: Ref<T[K]['default']> };
|
||||||
|
|
||||||
private connection = stream.useChannel('main');
|
|
||||||
|
|
||||||
constructor(key: string, def: T) {
|
constructor(key: string, def: T) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.keyForLocalStorage = 'pizzax::' + key;
|
this.keyForLocalStorage = 'pizzax::' + key;
|
||||||
|
@ -73,7 +73,7 @@ export class Storage<T extends StateDef> {
|
||||||
});
|
});
|
||||||
}, 1);
|
}, 1);
|
||||||
// streamingのuser storage updateイベントを監視して更新
|
// streamingのuser storage updateイベントを監視して更新
|
||||||
this.connection.on('registryUpdated', ({ scope, key, value }: { scope: string[], key: keyof T, value: T[typeof key]['default'] }) => {
|
connection?.on('registryUpdated', ({ scope, key, value }: { scope: string[], key: keyof T, value: T[typeof key]['default'] }) => {
|
||||||
if (scope[1] !== this.key || this.state[key] === value) return;
|
if (scope[1] !== this.key || this.state[key] === value) return;
|
||||||
|
|
||||||
this.state[key] = value;
|
this.state[key] = value;
|
||||||
|
|
Loading…
Reference in New Issue