Saturday, August 25, 2018

Understanding iOS NSNotification






iOS notification center delivers notifications to observers synchronously. In other words, when posting a notification, control does not return to the poster until all observers have received and processed the notification. 
To send notifications asynchronously use a notification queue, which is described in Notification Queues.
In a multithreaded application, notifications are always delivered in the thread in which the notification was posted, which may not be the same thread in which an observer registered itself.

This is similar to how javascript addEventListener and dispatchEvent works, so when dispatchEvent is called, the method will not return to caller until all added event listeners returns from their event handler call back methods.
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent

No comments:

Post a Comment