Java – alternative to observable pattern?
•
Java
When some state changes occur on object2, I need to perform some tasks on object1
Is there another way to use this pattern? Maybe other classes allow me to perform this behavior?
thank you.
Solution
Just add a field of type observable to object2, add observers to it, and call notifyobservers () when changes occur
This is the meaning of "in favor of composition rather than inheritance"
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码