Refactor update event and added state move #13
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request changes the tile update event structure, as it also adds an ability to
Move()
a state of a tile from one to another via a newMove()
method on aTile[T]
itself. This moves the state and notifies observers correctly (and only once) by dispatching an event with bothNew
andOld
tiles set, their location, and the state which was added/deleted. To accomplish this I needed to refactor a bunch of stuff as well.Enhancements to Observer Notification System:
UpdateState
struct to encapsulate the state of a tile before and after an update. (view.go
)pubsub
to includeNotify1
andNotify2
methods for handling notifications for single and multiple observers respectively. (view.go
) [1] [2]Improvements to Tile Update Mechanics:
writeTile
,mergeTile
,addObject
, anddelObject
methods to useUpdateState
for more granular update notifications. (grid.go
) [1] [2]Move
method toTile
struct to handle moving objects between tiles and notify observers accordingly. (grid.go
)