pradosoft / prado

Prado - Component Framework for PHP
Other
187 stars 70 forks source link

TEventSubscription for attaching and detaching event handlers #984

Closed belisoful closed 12 months ago

belisoful commented 1 year ago

I'd like to have a class that when given an object, its event, and a handler (with optional priority), it will remove the event when the class destructs.

Short term event handler attachments would be useful.

belisoful commented 1 year ago

omg. I found a third PHPStan bug: https://github.com/phpstan/phpstan/issues/9519

belisoful commented 1 year ago

BTW, This is ending up systematizing the newer collection classes. So IWeakCollection, IPriorityCollection, ICollectionFilter (for the IO filtering on the Weak collections) for each respective style of collection.

I'm also adding a TMap::add return value so that the key is returned. This way if the array key is null (for appending via []), then the new unknown (new) key is returned. This changes the TPriorityMap::add which returns the priority. I think returning the key is more important.