You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I love UnityMainThreadDispatcher; it solves a very simple problem well. However, I strongly dislike the static singleton anti-pattern used throughout the Unity ecosystem, and unfortunately this library is one of the culprits. I suggest adding the following interface:
which the UnityMainThreadDispatcherclass would implement. That way, developers can inject IUnityMainThreadDispatcher implementations (possibly their own) via dependency injection, mock it in unit tests, and generally avoid static cling in their code. This would not be a breaking change, as the static Instance method would still be present on the implementing class.
You can see my own version of this for reference in my personal UnityUtil library.
The text was updated successfully, but these errors were encountered:
I love
UnityMainThreadDispatcher
; it solves a very simple problem well. However, I strongly dislike the static singleton anti-pattern used throughout the Unity ecosystem, and unfortunately this library is one of the culprits. I suggest adding the following interface:which the
UnityMainThreadDispatcher
class would implement. That way, developers can injectIUnityMainThreadDispatcher
implementations (possibly their own) via dependency injection, mock it in unit tests, and generally avoid static cling in their code. This would not be a breaking change, as the staticInstance
method would still be present on the implementing class.You can see my own version of this for reference in my personal UnityUtil library.
The text was updated successfully, but these errors were encountered: