-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor event handling to consume base class for lifecycling
- Loading branch information
1 parent
34b8822
commit f1e21ba
Showing
23 changed files
with
172 additions
and
196 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
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
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
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,7 +1,7 @@ | ||
import { ICodeChangedEvent } from './Event/ICodeChangedEvent'; | ||
import { ISignal } from '@/infrastructure/Events/ISignal'; | ||
import { IEventSource } from '@/infrastructure/Events/IEventSource'; | ||
|
||
export interface IApplicationCode { | ||
readonly changed: ISignal<ICodeChangedEvent>; | ||
readonly changed: IEventSource<ICodeChangedEvent>; | ||
readonly current: string; | ||
} |
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,10 +1,10 @@ | ||
import { ISignal } from '@/infrastructure/Events/ISignal'; | ||
import { IEventSource } from '@/infrastructure/Events/IEventSource'; | ||
import { IFilterResult } from './IFilterResult'; | ||
|
||
export interface IUserFilter { | ||
readonly currentFilter: IFilterResult | undefined; | ||
readonly filtered: ISignal<IFilterResult>; | ||
readonly filterRemoved: ISignal<void>; | ||
readonly filtered: IEventSource<IFilterResult>; | ||
readonly filterRemoved: IEventSource<void>; | ||
setFilter(filter: string): void; | ||
removeFilter(): void; | ||
} |
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
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
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
5 changes: 2 additions & 3 deletions
5
src/infrastructure/Events/Signal.ts → src/infrastructure/Events/EventSource.ts
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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IEventSubscription } from './IEventSource'; | ||
|
||
export class EventSubscriptionCollection { | ||
private readonly subscriptions = new Array<IEventSubscription>(); | ||
public register(...subscriptions: IEventSubscription[]) { | ||
this.subscriptions.push(...subscriptions); | ||
} | ||
public unsubscribeAll() { | ||
this.subscriptions.forEach((listener) => listener.unsubscribe()); | ||
this.subscriptions.splice(0, this.subscriptions.length); | ||
} | ||
} |
9 changes: 7 additions & 2 deletions
9
src/infrastructure/Events/ISignal.ts → src/infrastructure/Events/IEventSource.ts
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,6 +1,11 @@ | ||
import { IEventSubscription } from './ISubscription'; | ||
export interface ISignal<T> { | ||
export interface IEventSource<T> { | ||
on(handler: EventHandler<T>): IEventSubscription; | ||
} | ||
|
||
export interface IEventSubscription { | ||
unsubscribe(): void; | ||
} | ||
|
||
export type EventHandler<T> = (data: T) => void; | ||
|
||
|
This file was deleted.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.