I intend to use observer pattern to update views automatically once value of model has been changed. It's obvious that a model is observable (subject) and DOM elements are observers that are staring at model for any changes so that they can update themselves.
But do you think it is still unidirectional data flow if I have a button which is observing model value and on click modify model value
The observer pattern is unidirectional, but your use case is bidirectional, while it's extending the observer pattern implementation.
The observer pattern defines, that the subject object will notify the observer if it's updated and the observer will implement an notify() function accordingly.
What you describe isn't part of that pattern. You can implement it and if data flows it would be bidirectional. But it is not part of the pattern definition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With