From 496ea34a9b3d60c6dceae2c1dc096e6ea19d63db Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 13 Mar 2022 18:55:47 -0500 Subject: [PATCH] Enabled using the BaseLayer features while creating the layer --- src/game/layers.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/game/layers.tsx b/src/game/layers.tsx index 0698c0a..2a7bc45 100644 --- a/src/game/layers.tsx +++ b/src/game/layers.tsx @@ -89,15 +89,19 @@ export type GenericLayer = Replace< } >; -export function createLayer(optionsFunc: () => T): Layer { +export function createLayer( + optionsFunc: (() => T) & ThisType +): Layer { return createLazyProxy(() => { - const layer = optionsFunc() as T & Partial; + const layer = {} as T & Partial; const emitter = (layer.emitter = createNanoEvents()); layer.on = emitter.on.bind(emitter); layer.emit = emitter.emit.bind(emitter); layer.minimized = persistent(false); + Object.assign(layer, optionsFunc.call(layer)); + processComputable(layer as T, "color"); processComputable(layer as T, "display"); processComputable(layer as T, "name");