Synchronous and Asynchronous callbacks
Hello, I'm looking for a solution to a problem which is described best as an observer pattern issue I guess.
The scenario is the following, client code can register a callback for one or a list of notifications.
This is currently solved by having a dictionary with the possible notifications as the keys and lists of methods being the values.
Notification sent, triggers the list of method to be called. Nothing fancy.
Now, where it gets trickier is that the client should be able to register synchronous and asynchronous callbacks because some of the actions can't be done in a synchronous callback like updating the statusbar of the UI as the main app would overwrite it.
I've read that this isn't a good idea of having synchronous and asynchronous callbacks but to be honest, I don't see how this could be solved otherwise, hence the question what to do in such a case?
And as I currently think that there is no other solution then to provide sync and async callback registration possibility how would a solution look like?
Two dicts, one for sync and the other for async registrations?
That would mean that each notification handler needs to execute one dict after the other.
In an ideal world, the notification handler wouldn't know about the difference at all and would call its list of methods(objects?)
Any tips for me?
Just to be sure as I don't know whether this is relevant,
each notification handler provides a different set of arguments to the
registered callback functions, hence the multiple notification handlers.