You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normally you can not declare concrete interfaces
and then subscribe to their interface types
and you realice you are coupling your concrete signal types to the receivers
for example.
Lets say I have a player and i want to save the game when i finish a level
Ok easy I create "
signalLevelCompleted" and then I subscribe it to my "SaveGameSystem"
then I also want to save when i reach a checkpoint
Again i create "SignalCheckpointReached"
and then I subscribe it to my "SaveGameSystem"
And then you realize you are coupling the types
"signalLevelCompleted" and "SignalCheckpointReached" to your "SaveGameSystem"
ohhh its not too good...
but lets give the power of the interfaces to the signals
So i have the SignalCheckPoint reached
and SignalLevelCompleted
Both implements ISignalGameSaver
My GameSaverSystem just Subscribes to ISignalSaveGame for saving the game
So when i shot any of that signals i automatically save the game
and if for example i create another signal for Achievements "SignalAchievementCompleted"
I just have to implement the interface to it so it saves the game automatically
It offers a lot of modularity and abstractions to signals
Since you are firing a concrete signal with the action you are doing
And giving them functionality trough Interface implementations
0 commit comments