-
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.
refactor(project): remove all interfaces
- Loading branch information
1 parent
2b00091
commit 85353ef
Showing
7 changed files
with
35 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,13 @@ | |
* @author Joel Hernandez <[email protected]> | ||
*/ | ||
|
||
import { NoelEventListenerManager } from './interfaces'; | ||
import { NoelEventListener } from './types'; | ||
import { NoelEventImp } from './event'; | ||
import { NoelEvent } from './event'; | ||
import { NoelEventReplayNotEnabled } from './errors'; | ||
import NoelImp from './noel'; | ||
|
||
export class NoelEventListenerManagerImp implements NoelEventListenerManager { | ||
constructor(private listener: NoelEventListener, private event: NoelEventImp, private noel: NoelImp) {} | ||
export class NoelEventListenerManager { | ||
constructor(private listener: NoelEventListener, private event: NoelEvent, private noel: NoelImp) {} | ||
|
||
remove() { | ||
// We remove it from noel instead of the event itself because noel will remove it | ||
|
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,13 +1,14 @@ | ||
/** | ||
* @author Joel Hernandez <[email protected]> | ||
*/ | ||
import { NoelEvent, NoelEventConfig, NoelEventListenerManager, NoelLogger } from './interfaces'; | ||
import { NoelEventConfig } from './interfaces'; | ||
import { NoelEventListener } from './types'; | ||
import { NoelEventListenerManagerImp } from './event-listener-manager'; | ||
import { NoelEventListenerManager } from './event-listener-manager'; | ||
import { NoelBufferSizeNotValidError, NoelEventConfigError, NoelEventListenerError, NoelEventReplayNotEnabled } from './errors'; | ||
import NoelImp from './noel'; | ||
import { NoelLogger } from './logger'; | ||
|
||
export class NoelEventImp implements NoelEvent { | ||
export class NoelEvent { | ||
private noel: NoelImp; | ||
private name: string; | ||
private replayEnabled: boolean; | ||
|
@@ -61,7 +62,7 @@ export class NoelEventImp implements NoelEvent { | |
if (typeof listener !== 'function') throw new NoelEventListenerError('Given listener is not a function'); | ||
const listeners = this.getListeners(); | ||
listeners.add(listener); | ||
return new NoelEventListenerManagerImp(listener, this, this.noel); | ||
return new NoelEventListenerManager(listener, this, this.noel); | ||
} | ||
|
||
removeListener(listener: NoelEventListener): 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,8 @@ | ||
/** | ||
* @author Joel Hernandez <[email protected]> | ||
*/ | ||
import { NoelEventListener } from './types'; | ||
import NoelImp from './noel'; | ||
|
||
export interface Noel { | ||
replayIsEnabled(): boolean; | ||
|
||
enableReplay(): void; | ||
|
||
disableReplay(): void; | ||
|
||
setReplayBufferSize(buffer: number): void; | ||
|
||
clearReplayBufferForEvent(eventName: string): void; | ||
|
||
clearEventsReplayBuffers(): void; | ||
|
||
setLogger(logger: NoelLogger): void; | ||
|
||
enableNoEventListenersWarning(): void; | ||
|
||
disableNoEventListenersWarning(): void; | ||
|
||
on(eventName: string, listener: NoelEventListener): NoelEventListenerManager; | ||
|
||
emit(eventName: string, ...eventArgs: Array<any>): void; | ||
|
||
removeListener(eventName: string, listener: NoelEventListener): void; | ||
|
||
removeAllListeners(eventName: string): void; | ||
|
||
getEvent(eventName: string): NoelEvent; | ||
|
||
removeEvent(eventName: string): void; | ||
} | ||
import { NoelLogger } from './logger'; | ||
|
||
export interface NoelConfig { | ||
replay?: boolean; | ||
|
@@ -43,38 +11,6 @@ export interface NoelConfig { | |
logger?: NoelLogger; | ||
} | ||
|
||
export interface NoelEventListenerManager { | ||
remove(): void; | ||
|
||
replay(bufferSize?: number): NoelEventListenerManager; | ||
} | ||
|
||
export interface NoelEvent { | ||
setLogger(logger: NoelLogger): void; | ||
|
||
enableNoListenersWarning(): void; | ||
|
||
disableNoListenersWarning(): void; | ||
|
||
enableReplay(): void; | ||
|
||
disableReplay(): void; | ||
|
||
emit(...eventArgs: Array<any>): void; | ||
|
||
on(listener: NoelEventListener): NoelEventListenerManager; | ||
|
||
removeListener(listener: NoelEventListener): void; | ||
|
||
clearReplayBuffer(): void; | ||
|
||
removeAllListeners(): void; | ||
|
||
setReplayBufferSize(replayBufferSize: number): void; | ||
|
||
getReplayBufferAmount(replayBufferAmount: number): Array<any>; | ||
} | ||
|
||
export interface NoelEventConfig { | ||
name: string; | ||
logger?: NoelLogger; | ||
|
@@ -83,7 +19,3 @@ export interface NoelEventConfig { | |
noListenersWarning?: boolean; | ||
noel: NoelImp; | ||
} | ||
|
||
export interface NoelLogger { | ||
warn(warn: string): 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
/** | ||
* @author Joel Hernandez <[email protected]> | ||
*/ | ||
import { NoelLogger } from './interfaces'; | ||
|
||
const consolePoly = { | ||
warn: () => {} | ||
}; | ||
|
||
export class NoelLoggerImp implements NoelLogger { | ||
private console: any; | ||
export class NoelLogger { | ||
private console?: any; | ||
|
||
constructor() { | ||
this.console = typeof console === 'undefined' ? consolePoly : console; | ||
|
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