-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring: Rename Repository to Adapter and AdapterPort
- Loading branch information
1 parent
66f7da5
commit e5c67c0
Showing
36 changed files
with
458 additions
and
459 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package adapter | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
"github.com/vertex-center/vertex/types" | ||
) | ||
|
||
type EventInMemoryAdapter struct { | ||
listeners *map[uuid.UUID]types.Listener | ||
} | ||
|
||
func NewEventInMemoryAdapter() types.EventAdapterPort { | ||
return &EventInMemoryAdapter{ | ||
listeners: &map[uuid.UUID]types.Listener{}, | ||
} | ||
} | ||
|
||
func (a *EventInMemoryAdapter) AddListener(l types.Listener) { | ||
(*a.listeners)[l.GetUUID()] = l | ||
} | ||
|
||
func (a *EventInMemoryAdapter) RemoveListener(l types.Listener) { | ||
delete(*a.listeners, l.GetUUID()) | ||
} | ||
|
||
func (a *EventInMemoryAdapter) Send(e interface{}) { | ||
for _, l := range *a.listeners { | ||
l.OnEvent(e) | ||
} | ||
} |
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.