-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from takker99/event-type
👍 the type of event is generic
- Loading branch information
Showing
1 changed file
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
export type BaseStoreListenerInit<Derived extends BaseStore> = { | ||
export type BaseStoreListenerInit<Event, Derived extends BaseStore<Event>> = { | ||
store: Derived; | ||
event: string; | ||
event: Event; | ||
}; | ||
export type BaseStoreListener<Derived extends BaseStore> = ( | ||
init: BaseStoreListenerInit<Derived>, | ||
export type BaseStoreListener<Event, Derived extends BaseStore<Event>> = ( | ||
init: BaseStoreListenerInit<Event, Derived>, | ||
) => void; | ||
export declare class BaseStore { | ||
export declare class BaseStore<Event = string> { | ||
constructor(); | ||
|
||
public addChangeListener(listener: BaseStoreListener<this>): void; | ||
public removeChangeListener(listener: BaseStoreListener<this>): void; | ||
public addChangeListener(listener: BaseStoreListener<Event, this>): void; | ||
public removeChangeListener(listener: BaseStoreListener<Event, this>): void; | ||
public emitChange(event: string): void; | ||
public get listenersCount(): number; | ||
|
||
private _onChangeListeners: BaseStoreListener<this>[]; | ||
private _onChangeListeners: BaseStoreListener<Event, this>[]; | ||
} |