From 5d9ce6da2a614a959adf03e3364137156d6b0821 Mon Sep 17 00:00:00 2001
From: Philippe Auriach
Date: Wed, 15 Jun 2016 11:05:22 +0200
Subject: [PATCH] added completion handler to setupInitialViewState
---
StatefulViewController/StatefulViewController.swift | 2 +-
.../StatefulViewControllerImplementation.swift | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/StatefulViewController/StatefulViewController.swift b/StatefulViewController/StatefulViewController.swift
index 420f958..99c3d28 100644
--- a/StatefulViewController/StatefulViewController.swift
+++ b/StatefulViewController/StatefulViewController.swift
@@ -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.
diff --git a/StatefulViewController/StatefulViewControllerImplementation.swift b/StatefulViewController/StatefulViewControllerImplementation.swift
index 6a1fa0d..a204029 100644
--- a/StatefulViewController/StatefulViewControllerImplementation.swift
+++ b/StatefulViewController/StatefulViewControllerImplementation.swift
@@ -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) {