Dependencies Injection trong Android - Phần 4: Scopes với Dagger2
Lời giới thiệu
Đã bao giờ bạn biết tới Singleton Design pattern chưa? Đôi lúc bạn chỉ muốn có một instance duy nhất trong toàn app vì những lí do sau:
Nhiều khi một instance rất tốn nhiều bước để tạo và bạn không muốn tạo một instance mới, mà lại được quá nhiều chỗ trong app sử dụng, như là instance RetrofitService, instance JsonParser, instance OkHttpClient. Cho dù cả việc tạo mới đã có Dagger lo,...
Dependency Injection
Android
1659