Closed danpecher closed 4 years ago
@schwarja you were right, the way I did it wouldn't really work. So I fundamentally changed how listeners are used:
ListenerIdentifier
ListenerArguments
to identify listeners of one set of arguments (number of items per page for example)IdentifiableClosure
to identify closures that the user registers. Only ObjectIdentifier
is returned to him so it's basically the same as before (with ListenerIdentifier
- also a string)So if someone registers 3 listeners to conversations with page size of n
, they will be stored under ListenerArguments.conversations(pageSize: n)
as an array of 3 IdentifiableClosure
s. The user will get 3 ObjectIdentifiers
which he can later use to deregister given closures.
I hope it makes sense 😁
Listeners are now described using
ListenerArguments
which carry arguments based on data type (messages/conversations). Each ListenerArgument key has a dictionary associated with it that consists of aListenerIdentifier
as the key and the closure to be run as the value. This way individual closures can be removed independently based on the arguments and identifier.