Skip to content

Commit

Permalink
prefers private(set) to readonly computer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasloisp committed Aug 21, 2021
1 parent 1268db1 commit ddb1ad6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 4 additions & 5 deletions MoViesC/Controller/MovieListing/MovieListingPageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ protocol MovieListingPager: AnyObject {

class MovieListingPageManager {
var totalItems: Int { return totalMovies }
var isFetchInProgress: Bool { return _isFetchInProgress }
var isInFirstPage: Bool { return currentPage == 1 }
private(set) var isFetchInProgress: Bool = false

private let pager: MovieListingPager
private var currentPage = 1
private var totalMovies = 0
private var _isFetchInProgress: Bool = false

init(pager: MovieListingPager) {
self.pager = pager
Expand All @@ -31,15 +30,15 @@ class MovieListingPageManager {
}

func fetchPage(currentCount: Int, completionHandler: @escaping ((MoviePage?) -> Void)) {
guard !_isFetchInProgress else {
guard !isFetchInProgress else {
return
}
_isFetchInProgress = true
isFetchInProgress = true

let page = currentPage

self.pager.fetchPage(page: page) { moviePage in
self._isFetchInProgress = false
self.isFetchInProgress = false
if let moviePage = moviePage {
self.currentPage += 1
self.totalMovies = moviePage.totalResults
Expand Down
5 changes: 2 additions & 3 deletions MoViesC/Controller/MovieSharing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ class MovieSharing {

weak var delegate: MovieSharingDelegate?

var isInitialized: Bool { _isInitialized }
private(set) var isInitialized: Bool = false
private let multiPeer: MultiPeer
private var _isInitialized = false

private init() {
self.multiPeer = MultiPeer.instance
Expand All @@ -42,7 +41,7 @@ class MovieSharing {
multiPeer.initialize(serviceType: Self.serviceType)
multiPeer.autoConnect()
multiPeer.delegate = self
self._isInitialized = true
self.isInitialized = true
}

private func onReceive(movieId: Int) {
Expand Down

0 comments on commit ddb1ad6

Please sign in to comment.