Skip to content

Commit

Permalink
Merge pull request #42 from takker99/use-derived-class
Browse files Browse the repository at this point in the history
👍 Use a derived class at listener arguments
  • Loading branch information
takker99 authored Mar 23, 2023
2 parents f26769f + 9fe855c commit 29123a1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions baseStore.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
export type BaseStoreListenerInit = { store: BaseStore; event: string };
export type BaseStoreListener = (init: BaseStoreListenerInit) => void;
export type BaseStoreListenerInit<Derived extends BaseStore> = {
store: Derived;
event: string;
};
export type BaseStoreListener<Derived extends BaseStore> = (
init: BaseStoreListenerInit<Derived>,
) => void;
export declare class BaseStore {
constructor();

public addChangeListener(listener: BaseStoreListener): void;
public removeChangeListener(listener: BaseStoreListener): void;
public addChangeListener(listener: BaseStoreListener<this>): void;
public removeChangeListener(listener: BaseStoreListener<this>): void;
public emitChange(event: string): void;
public get listenersCount(): number;

private _onChangeListeners: BaseStoreListener[];
private _onChangeListeners: BaseStoreListener<this>[];
}

0 comments on commit 29123a1

Please sign in to comment.