Skip to content

Commit

Permalink
add makeWrappable helper
Browse files Browse the repository at this point in the history
  • Loading branch information
timbasel committed Oct 19, 2024
1 parent 65ccbc5 commit a472b46
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/solid/store/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(obj: T) {
Object.defineProperty(obj, $WRAP, { value: true });
}

/**
* Returns the underlying data in the store without a proxy.
* @param item store proxy object
Expand Down

0 comments on commit a472b46

Please sign in to comment.