Observer Pattern Tutorial

Опубликовано: 01 Ноябрь 2021
на канале: Coding With Adam
5,612
146

In this exciting tutorial we are going to learn about the observer pattern. Not your typical observer pattern tutorial. We toss the wikipedia article aside and apply the observer pattern to a game.

The game is simple, click the buttons at the top of the screen and the characters will perform the action. We coordinate the actions through the observer pattern.

At its core the pattern revolves around a subject that the observer will observe. The subject has a list of observers(one-to-many relationship). Observers can choose to register with the subject. The subject at any point in time can notify the observers by looping through all observers and calling the update method.

For example let's say the our subject is the YouTube channel Coding With Adam. The observers would be YouTube users. YouTube users can register with the subject by subscribing. When the YouTube channel owner(subject) uploads a new video they can notify all subscribers(observers).

Learn more by watching the video.

Github:
https://github.com/CodingWith-Adam/ob...

Try it here:
https://codingwith-adam.github.io/obs...


Смотрите видео Observer Pattern Tutorial онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Coding With Adam 01 Ноябрь 2021. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 5,612 раз и оно понравилось 146 посетителям.