Observer-Pattern code snippet