@byloth/core 2.0.0-rc.8 → 2.0.0-rc.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byloth/core",
3
- "version": "2.0.0-rc.8",
3
+ "version": "2.0.0-rc.9",
4
4
  "description": "An unopinionated collection of useful functions and classes that I use widely in all my projects. 🔧",
5
5
  "keywords": [
6
6
  "Core",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = "2.0.0-rc.8";
1
+ export const VERSION = "2.0.0-rc.9";
2
2
 
3
3
  export type { Constructor, Interval, Timeout } from "./core/types.js";
4
4
 
@@ -12,7 +12,7 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
12
12
  this._subscribers = new Map();
13
13
  }
14
14
 
15
- public subscribe<K extends keyof T, S extends T[K]>(event: K, subscriber: S): () => void
15
+ public subscribe<K extends keyof T>(event: K, subscriber: T[K]): () => void
16
16
  {
17
17
  if (!(this._subscribers.has(event))) { this._subscribers.set(event, []); }
18
18
 
@@ -32,13 +32,13 @@ export default class Publisher<T extends { [K in keyof T]: Callback<any[], any>
32
32
  };
33
33
  }
34
34
 
35
- public publish<K extends keyof T, A extends Parameters<T[K]>, R extends ReturnType<T[K]>>(event: K, ...args: A): R[]
35
+ public publish<K extends keyof T>(event: K, ...args: Parameters<T[K]>): ReturnType<T[K]>[]
36
36
  {
37
37
  const subscribers = this._subscribers.get(event);
38
38
  if (!(subscribers)) { return []; }
39
39
 
40
40
  return subscribers.slice()
41
- .map((subscriber) => subscriber(...args)) as R[];
41
+ .map((subscriber) => subscriber(...args)) as ReturnType<T[K]>[];
42
42
  }
43
43
 
44
44
  public readonly [Symbol.toStringTag]: string = "Publisher";
@@ -99,6 +99,10 @@ export default class SwitchableCallback<T extends Callback<any[], any> = Callbac
99
99
  }
100
100
 
101
101
  this._key = key;
102
- this._callback = this._callbacks.get(key)!;
102
+
103
+ if (this._isEnabled)
104
+ {
105
+ this._callback = this._callbacks.get(key)!;
106
+ }
103
107
  }
104
108
  }