20 ms·
This seems similar to Cocoa's NSNotificationCenter, where you can post messages or subscribe to messages. One of the better Cocoa books motivates it with the f
by mcphage 9y ago
This seems similar to Cocoa's NSNotificationCenter, where you can post messages or subscribe to messages.
One of the better Cocoa books motivates it with the following example:
Say you have an app with multiple windows. You also have a settings pane, where you can change the background color of your windows. You don't want the "background color" component to keep track of all of the open windows in the app, that's not at all related to its responsibility. So instead you use the notification center to post a message "hey the user changed the window background color to blue", and windows will subscribe to "the user changed the window background color" messages. This way the color picker and the windows themselves can work together, without ever caring about the others' existence.