Skip to content

Commit 5d9ce6d

Browse files
added completion handler to setupInitialViewState
1 parent e23246e commit 5d9ce6d

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

StatefulViewController/StatefulViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public protocol StatefulViewController: class, BackingViewProvider {
4848
/// Sets up the initial state of the view.
4949
/// This method should be called as soon as possible in a view or view controller's
5050
/// life cycle, e.g. `viewWillAppear:`, to transition to the appropriate state.
51-
func setupInitialViewState()
51+
func setupInitialViewState(completion: (() -> Void)?)
5252

5353
/// Transitions the controller to the loading state and shows
5454
/// the loading view if there is no content shown already.

StatefulViewController/StatefulViewControllerImplementation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ extension StatefulViewController {
6262

6363
// MARK: Transitions
6464

65-
public func setupInitialViewState() {
65+
public func setupInitialViewState(completion: (() -> Void)? = nil) {
6666
let isLoading = (lastState == .Loading)
6767
let error: NSError? = (lastState == .Error) ? NSError(domain: "com.aschuch.StatefulViewController.ErrorDomain", code: -1, userInfo: nil) : nil
68-
transitionViewStates(isLoading, error: error, animated: false)
68+
transitionViewStates(isLoading, error: error, animated: false, completion: completion)
6969
}
7070

7171
public func startLoading(animated: Bool = false, completion: (() -> Void)? = nil) {

0 commit comments

Comments
 (0)