Created
September 25, 2023 12:51
-
-
Save mcgill-a/7f92a1d32fed02b5dd4541ba53483aed to your computer and use it in GitHub Desktop.
A minimal frontend service for updating user data in Angular
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
@Injectable({ providedIn: 'root' }) | |
constructor(private socketService: SocketService) { | |
this.subs.add( | |
this.socketService.userChange.subscribe((change: UserChange) => { | |
const {user, action} = change; | |
switch (change.action) { | |
case UserAction.join: | |
case TeamAction.position: | |
this._users.set(user.email, user); | |
break; | |
case UserAction.leave: | |
this._users.delete(user.email); | |
break; | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment