File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
packages/signalizejs/src/modules Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ export default () => {
44 * @template T
55 * @type {import('../../types/modules/signal').Signal<T> }
66 */
7- class Signal extends Function {
7+ class Signal {
88 /** @type {T } */
99 value ;
1010
@@ -17,19 +17,21 @@ export default () => {
1717
1818 /** @param {T } defaultValue */
1919 constructor ( defaultValue ) {
20- super ( ) ;
2120 this . value = defaultValue ;
2221
23- return new Proxy ( this , {
24- apply : ( target , thisArg , args ) => {
25- if ( args . length === 1 ) {
26- this . #set( args [ 0 ] ) ;
27- return this . value ;
28- }
29-
30- return this . #get( ) ;
22+ // In order to make signal callable and to be able to check if created signal is instanceof Signal
23+ // We have to create this function and bind a protype of the Signal to it
24+ const callable = ( ...args ) => {
25+ if ( args . length === 1 ) {
26+ this . #set( args [ 0 ] ) ;
27+ return this . value ;
3128 }
32- } ) ;
29+ return this . #get( ) ;
30+ } ;
31+
32+ Object . setPrototypeOf ( callable , this ) ;
33+
34+ return callable ;
3335 }
3436
3537 /**
You can’t perform that action at this time.
0 commit comments