-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce Delayed Subscription Feature in Emitter with Comprehensive Tests - Implemented 'subscribeWithDelay' method in Emitter class, allowing delayed callback execution. - Added extensive test suite for 'subscribeWithDelay', covering: - Basic delayed callback functionality. - Unsubscribing callbacks before and after delay periods. - Independent execution of multiple delayed subscriptions. - Correct execution order for callbacks with different delays. - Handling of the same callback registered with varying delays. - Behavior with zero delay (immediate execution). - Ensured robustness of new feature with edge case handling and error scenarios. This update significantly enhances the Emitter's capabilities, allowing for more flexible event handling scenarios. * documentation updated * documentation table of context improved * style: Emitter imports * style: imports single quote * Doc. update * test: Added tests for event emitter with delayed subscriptions, covering zero delay handling, multiple subscriptions with varying delays, correct execution order based on delay, and no execution on unsubscribe before delayed callback. * test: remove duplication from subscribeWithDelay test --------- Co-authored-by: Valeh ASADLI <[email protected]>
- Loading branch information
1 parent
6676af5
commit 532935b
Showing
16 changed files
with
280 additions
and
57 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
// Indicates whether the coverage information should be collected while executing the test | ||
collectCoverage: true, | ||
|
||
// The directory where Jest should output its coverage files | ||
coverageDirectory: "coverage", | ||
|
||
// Indicates whether each individual test should be reported during the run | ||
verbose: true, | ||
|
||
// The test environment that will be used for testing | ||
testEnvironment: "node", | ||
|
||
// The glob patterns Jest uses to detect test files | ||
testMatch: [ | ||
"<rootDir>/tests/**/*.[jt]s?(x)", | ||
"<rootDir>/tests/?(*.)+(spec|test).[tj]s?(x)" | ||
], | ||
|
||
// A map from regular expressions to paths to transformers | ||
transform: { | ||
"^.+\\.(ts|tsx)?$": "babel-jest" | ||
}, | ||
}; |
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
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,8 @@ | ||
export interface IEventWithDelaySubscriber<T extends Record<string, (...args: any[]) => void>> { | ||
subscribeWithDelay<K extends keyof T>( | ||
name: K, | ||
callback: T[K], | ||
delay: number, | ||
priority?: number | ||
): () => 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
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.