Skip to content

Commit

Permalink
Merge pull request #27 from philippeauriach/setupInitialViewState-com…
Browse files Browse the repository at this point in the history
…pletion

Added completion handler to setupInitialViewState
  • Loading branch information
aschuch committed Jun 15, 2016
2 parents e23246e + 5d9ce6d commit a82e45a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion StatefulViewController/StatefulViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public protocol StatefulViewController: class, BackingViewProvider {
/// Sets up the initial state of the view.
/// This method should be called as soon as possible in a view or view controller's
/// life cycle, e.g. `viewWillAppear:`, to transition to the appropriate state.
func setupInitialViewState()
func setupInitialViewState(completion: (() -> Void)?)

/// Transitions the controller to the loading state and shows
/// the loading view if there is no content shown already.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ extension StatefulViewController {

// MARK: Transitions

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

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

0 comments on commit a82e45a

Please sign in to comment.