Skip to content

Commit

Permalink
add makeWrappable helper
Browse files Browse the repository at this point in the history
  • Loading branch information
timbasel committed Apr 14, 2024
1 parent fbf5490 commit ef64150
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/solid/store/src/store.ts
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 ef64150

Please sign in to comment.