Let's use Resolver
library to it's final potential, shall we?
Direct tdApi
calls in views are not good, in fact, it really bad. How it should be replaced:
Example: we have a chat view. It should show messages, and populate the status bar and other things.
For that, there should be a variable:
@Injected private var dataSource: ChatDataSourcable
Where ChatDataSourcable
is:
protocol ChatDataSourcable
Why? Simple: Previews and testing!
We can easily create something like:
final class TdChatDataSource: ChatDataSourcable
Which will have a real implementation with real data, and also:
final class MockChatDataSource: ChatDataSourcable
For using in Previews and testing.
Each instance can be easily injected using:
Resolver.register { TdChatDataSource() as ChatDataSourcable }
I think benefits are huge for this one :D