Observer Pattern - Design Patterns in JavaScript

Published: 24 March 2022
on channel: TomDoesTech
8,355
256

Repository: https://github.com/TomDoesTech/js-des...

The observer pattern makes use of observable objects to make your code reactive. An observable is an object (the subject) that maintains a list of dependents (observers) and notifies them when the state changes, usually by calling a broadcast method.

An example of the observable pattern is EventTarget.addEventListener(). addEventListener allows you to subscribe to an event on the DOM and provide a callback function. When that event happens, your callback function will be executed.

0:00 Introduction
1:37 Create observable with a class
3:46 Using the observable
5:05 Observable factory function
6:08 Practical example

🌎 Follow me here:
Discord:   / discord  
Twitter:   / tomdoes_tech  
Facebook:   / tomdoestech​  
Instagram:   / tomdoestech​  
TikTok:   / tomdoes_tech  
☕ Buy me a coffee: https://www.buymeacoffee.com/tomn


On this page of the site you can watch the video online Observer Pattern - Design Patterns in JavaScript with a duration of hours minute second in good quality, which was uploaded by the user TomDoesTech 24 March 2022, share the link with friends and acquaintances, this video has already been watched 8,355 times on youtube and it was liked by 256 viewers. Enjoy your viewing!