Skip to content

Commit a472b46

Browse files
committed
add makeWrappable helper
1 parent 65ccbc5 commit a472b46

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/solid/store/src/store.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ export function isWrappable(obj: any) {
7979
);
8080
}
8181

82+
/**
83+
* Forces an object/class to get wrapped
84+
* @param obj object
85+
* @example
86+
* ```js
87+
* class Example {
88+
* constructor() {
89+
* makeWrappable(this) // make every instance of a class wrap
90+
* }
91+
* }
92+
* ```
93+
*/
94+
export function makeWrappable<T>(obj: T) {
95+
Object.defineProperty(obj, $WRAP, { value: true });
96+
}
97+
8298
/**
8399
* Returns the underlying data in the store without a proxy.
84100
* @param item store proxy object

0 commit comments

Comments
 (0)