File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ export class TwoAndEight {
66 #listeners: ( ( ) => void ) [ ] = [ ]
77
88 constructor ( ) {
9+ this . $subscribe = this . $subscribe . bind ( this )
10+ this . $reset = this . $reset . bind ( this )
11+
912 const p = new Proxy ( this , {
1013 set : ( _ , key , value ) => {
1114 const prevValue = Reflect . get ( this , key )
@@ -34,14 +37,14 @@ export class TwoAndEight {
3437 autoBind ( p )
3538 }
3639
37- $subscribe = ( listener : ( ) => void ) => {
40+ $subscribe ( listener : ( ) => void ) {
3841 this . #listeners = [ ...this . #listeners, listener ]
3942 return ( ) : void => {
4043 this . #listeners = this . #listeners. filter ( ( l ) => l !== listener )
4144 }
4245 }
4346
44- $reset = ( field ?: keyof this) : void => {
47+ $reset ( field ?: keyof this) : void {
4548 if ( field ) {
4649 if ( typeof this [ field ] === 'function' ) {
4750 throw new TypeError ( '2n8: Cannot reset a method.' )
@@ -59,7 +62,7 @@ export class TwoAndEight {
5962 this . #emitChange( )
6063 }
6164
62- #emitChange = ( ) => {
65+ #emitChange( ) {
6366 for ( const listener of this . #listeners) {
6467 listener ( )
6568 }
You can’t perform that action at this time.
0 commit comments