From a472b468d58498a08692d21b291874f98fefa5f3 Mon Sep 17 00:00:00 2001 From: Tim Basel Date: Mon, 15 Apr 2024 01:43:47 +0200 Subject: [PATCH] add `makeWrappable` helper --- packages/solid/store/src/store.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/solid/store/src/store.ts b/packages/solid/store/src/store.ts index 2c4fef40..19711c13 100644 --- a/packages/solid/store/src/store.ts +++ b/packages/solid/store/src/store.ts @@ -79,6 +79,22 @@ export function isWrappable(obj: any) { ); } +/** + * Forces an object/class to get wrapped + * @param obj object + * @example + * ```js + * class Example { + * constructor() { + * makeWrappable(this) // make every instance of a class wrap + * } + * } + * ``` + */ +export function makeWrappable(obj: T) { + Object.defineProperty(obj, $WRAP, { value: true }); +} + /** * Returns the underlying data in the store without a proxy. * @param item store proxy object