-
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.
chapter 04: adding role and header interfaces to use in entityManager
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
chapter-04-the-interface-segregation-principle/refactor/entityManager.js
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,44 @@ | ||
/** | ||
* In order to improve the understanding of this code, this file it is supposing to implement the following interfaces: | ||
* | ||
* interface PersistsEntitiesInterface { | ||
* function persist(entity); | ||
* | ||
* function flush(); | ||
* } | ||
* | ||
* interface HasUnitOfWorkInterface { | ||
* function getUnitOfWork(name); | ||
* } | ||
* | ||
* interface EntityManagerInterface extends PersistsEntitiesInterface, HasUnitOfWorkInterface { | ||
* | ||
* } | ||
* | ||
* Quack Quack Quack 🦆 typing :D | ||
*/ | ||
|
||
/** | ||
* @implements {EntityManagerInterface} | ||
*/ | ||
function entityManager() { | ||
function persist(entity) { | ||
// make something here... | ||
} | ||
|
||
function flush() { | ||
// make something here | ||
} | ||
|
||
function getUnitOfWork() { | ||
// make something here | ||
} | ||
|
||
return { | ||
persist, | ||
flush, | ||
getUnitOfWork, | ||
}; | ||
} | ||
|
||
module.exports = entityManager; |