Created
January 5, 2018 12:57
-
-
Save vialyx/100c85f78b41226df27620f845112709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol ResourceType { | |
func load() | |
} | |
protocol PagginationProtocol { | |
var offset: UInt { get set } | |
var limit: UInt! { get set } | |
var hasMore: Bool { get } | |
func loadMore() | |
} | |
final class ProfileInteractor: ResourceType { | |
func load() { | |
// TODO: - Make URLRequest | |
print("\(self) load") | |
} | |
} | |
final class UsersListInteractor: ResourceType, PagginationProtocol { | |
var offset: UInt | |
var limit: UInt! | |
var hasMore: Bool | |
init() { | |
offset = 0 | |
hasMore = true | |
} | |
func load() { | |
// TODO: - Make URLRequest | |
print("\(self) load") | |
} | |
func loadMore() { | |
offset = offset + 10 | |
load() | |
print("\(self) loadMore \(offset)") | |
} | |
} | |
let profileInteractor = ProfileInteractor() | |
profileInteractor.load() | |
let usersListInteractor = UsersListInteractor() | |
usersListInteractor.limit = 30 | |
usersListInteractor.loadMore() | |
if usersListInteractor.hasMore { | |
usersListInteractor.loadMore() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment