forked from profectus/Profectus
Enabled using the BaseLayer features while creating the layer
This commit is contained in:
parent
77a3d92075
commit
496ea34a9b
1 changed files with 6 additions and 2 deletions
|
@ -89,15 +89,19 @@ export type GenericLayer = Replace<
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export function createLayer<T extends LayerOptions>(optionsFunc: () => T): Layer<T> {
|
export function createLayer<T extends LayerOptions>(
|
||||||
|
optionsFunc: (() => T) & ThisType<BaseLayer>
|
||||||
|
): Layer<T> {
|
||||||
return createLazyProxy(() => {
|
return createLazyProxy(() => {
|
||||||
const layer = optionsFunc() as T & Partial<BaseLayer>;
|
const layer = {} as T & Partial<BaseLayer>;
|
||||||
const emitter = (layer.emitter = createNanoEvents<LayerEvents>());
|
const emitter = (layer.emitter = createNanoEvents<LayerEvents>());
|
||||||
layer.on = emitter.on.bind(emitter);
|
layer.on = emitter.on.bind(emitter);
|
||||||
layer.emit = emitter.emit.bind(emitter);
|
layer.emit = emitter.emit.bind(emitter);
|
||||||
|
|
||||||
layer.minimized = persistent(false);
|
layer.minimized = persistent(false);
|
||||||
|
|
||||||
|
Object.assign(layer, optionsFunc.call(layer));
|
||||||
|
|
||||||
processComputable(layer as T, "color");
|
processComputable(layer as T, "color");
|
||||||
processComputable(layer as T, "display");
|
processComputable(layer as T, "display");
|
||||||
processComputable(layer as T, "name");
|
processComputable(layer as T, "name");
|
||||||
|
|
Loading…
Reference in a new issue