@v4fire/client
Version:
V4Fire client core library
110 lines (91 loc) • 2.19 kB
text/typescript
/*!
* V4Fire Client Core
* https://github.com/V4Fire/Client
*
* Released under the MIT license
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/
/**
* [[include:dummies/b-dummy-watch/README.md]]
* @packageDocumentation
*/
import watch from 'core/object/watch';
import iData, { component, field, system, computed, ModsDecl } from 'super/i-data/i-data';
export * from 'super/i-data/i-data';
({
functional: {
functional: true,
dataProvider: undefined
}
})
export default class bDummyWatch extends iData {
(() => new Set([]))
setField!: Set<string>;
()
complexObjStore: Dictionary = {
a: {
b: {
c: 1,
d: 2
}
}
};
()
systemComplexObjStore: Dictionary = {
a: {
b: {
c: 1,
d: 2
}
}
};
get complexObj(): Dictionary {
return Object.fastClone(this.complexObjStore);
}
({dependencies: ['r.isAuth']})
get remoteWatchableGetter(): boolean {
return this.r.isAuth;
}
({cache: true, dependencies: ['complexObjStore']})
get cachedComplexObj(): Dictionary {
return Object.fastClone(this.complexObjStore);
}
({dependencies: ['cachedComplexObj']})
get cachedComplexDecorator(): Dictionary {
return Object.fastClone(this.cachedComplexObj);
}
({cache: false})
get systemComplexObj(): Dictionary {
return Object.fastClone(this.systemComplexObjStore);
}
({dependencies: ['cachedComplexObj', 'systemComplexObjStore', 'remoteWatchableGetter']})
get smartComputed(): Dictionary {
return {
a: this.cachedComplexObj.a,
b: (this.field.get<number>('systemComplexObjStore.a.b.c') ?? 0) + 10,
remoteWatchableGetter: this.remoteWatchableGetter
};
}
({cache: true, watchable: true})
get mountedArrayWatcher(): unknown[] {
return watch([]).proxy;
}
({cache: true, watchable: true})
get mountedWatcher(): Dictionary {
return watch({}).proxy;
}
({dependencies: ['mountedWatcher']})
get mountedComputed(): Dictionary {
return this.mountedWatcher;
}
static override readonly mods: ModsDecl = {
watchable: [
'val-1',
'val-2'
],
nonWatchable: [
['val-1'],
'val-2'
]
};
}