strvcom / ios-chat-component

Chat modular library
MIT License
1 stars 1 forks source link

Store listeners based on their arguments #24

Closed danpecher closed 4 years ago

danpecher commented 4 years ago

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 a ListenerIdentifier 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.

danpecher commented 4 years ago

@schwarja you were right, the way I did it wouldn't really work. So I fundamentally changed how listeners are used:

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 IdentifiableClosures. The user will get 3 ObjectIdentifiers which he can later use to deregister given closures.

I hope it makes sense 😁