mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-27 00:37:14 +09:00
Convert overloads to generic function
Co-authored-by: Hornwitser <github@hornwitser.no>
This commit is contained in:
1 parent
d58602f1a1
commit
54cb483a31
1 file changed
+2
-7
@@ -131,11 +131,7 @@ export class SubscriptionController {
|
|||||||
* Allow clients to subscribe to an event by telling the subscription controller to accept them
|
* Allow clients to subscribe to an event by telling the subscription controller to accept them
|
||||||
* Has an optional subscription update handler which is called when any client updates their subscription
|
* Has an optional subscription update handler which is called when any client updates their subscription
|
||||||
*/
|
*/
|
||||||
handle<T>(Event: EventClass<T>, subscriptionUpdate?: SubscriptionRequestHandler<T>,): void;
|
handle<T>(Event: EventClass<T>, subscriptionUpdate?: SubscriptionRequestHandler<T>) {
|
||||||
handle(
|
|
||||||
Event: EventClass<unknown>,
|
|
||||||
subscriptionUpdate?: SubscriptionRequestHandler<unknown>,
|
|
||||||
) {
|
|
||||||
const entry = Link._eventsByClass.get(Event);
|
const entry = Link._eventsByClass.get(Event);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
throw new Error(`Unregistered Event class ${Event.name}`);
|
throw new Error(`Unregistered Event class ${Event.name}`);
|
||||||
@@ -152,8 +148,7 @@ export class SubscriptionController {
|
|||||||
/**
|
/**
|
||||||
* Broadcast an event to all subscribers of that event, will be filtered by channel if a ChannelEvent is provided
|
* Broadcast an event to all subscribers of that event, will be filtered by channel if a ChannelEvent is provided
|
||||||
*/
|
*/
|
||||||
broadcast<T>(event: Event<T> | ChannelEvent<T>): void;
|
broadcast<T>(event: Event<T> | ChannelEvent<T>) {
|
||||||
broadcast(event: Event<unknown> | ChannelEvent<unknown>) {
|
|
||||||
const entry = Link._eventsByClass.get(event.constructor);
|
const entry = Link._eventsByClass.get(event.constructor);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
throw new Error(`Unregistered Event class ${event.constructor.name}`);
|
throw new Error(`Unregistered Event class ${event.constructor.name}`);
|
||||||
|
|||||||
Reference in new issue
Block a user