How could we override what will happen on Love event will be dispatched?
This question was raised many times before. Each time I've returned to it a new ideas come into my mind but all of them have their pros and cons. Finally I've got all pieces together and ready to share with my vision.
Thanks to Pavel Volkov for helping me out with better solution.
First, we should encapsulate increment & decrement logic in jobs. Because we will be able to run those jobs from any place in any time without dispatching an event (which may be listened by many listeners at moment). Listeners will become very simple and synchronous but they will dispatch queued jobs.
Second, we should have more control over the queue. Because developers should be able to choose if they want to use stock package behavior or they want to modify it to their application requirements.
I've designed 4 different implementations of the second part. Each implementation will be described in separate comment.
Spoiler: 4th solution will be implemented https://github.com/cybercog/laravel-love/issues/145#issuecomment-583730266
该提问来源于开源项目:cybercog/laravel-love