Understanding the publisher-subscriber design pattern