Skip to content

Commit 197fe56

Browse files
committed
~ Show $ methods as methods in IDE
1 parent d63ec4b commit 197fe56

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/2n8.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)