Last active
December 15, 2016 10:30
-
-
Save dodikk/b547701f0dbad794d33f2ad1c198e1e5 to your computer and use it in GitHub Desktop.
Swift compiler error related to FutureKit callbacks
This file contains hidden or 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
| PKLoginModelPromise.swift:62:22: error: enum element 'main' cannot be referenced as an instance member | |
| .onFail(.main, block: | |
| ^ |
This file contains hidden or 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
| github "FutureKit/FutureKit" "v3" | |
| github "ReSwift/ReSwift" == 3.0.0 | |
| github "ReSwift/ReSwiftRouter" == 0.5.1 |
This file contains hidden or 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
| public class PKLoginModelPromise : PKLoginModel | |
| { | |
| private let reduxStore: PKAppStateStore | |
| private let networkLoader: PKLoginService | |
| private let tokenRepo: PKAccessTokenRepo | |
| public init(withReduxStore reduxStore: PKAppStateStore, | |
| networkLoader: PKLoginService, | |
| tokenRepo: PKAccessTokenRepo) | |
| { | |
| self.reduxStore = reduxStore | |
| self.networkLoader = networkLoader | |
| self.tokenRepo = tokenRepo | |
| } | |
| public func loginAsync( | |
| _ email: String, | |
| password: String) | |
| { | |
| let loginFromNetFuture: FetchAccessTokenFuture = | |
| LoginFutures.login( | |
| withService: self.networkLoader, | |
| email: email, | |
| password: password) | |
| let tokenRepo = self.tokenRepo | |
| let reduxStore = self.reduxStore | |
| loginFromNetFuture.onSuccess(.background, block: | |
| { | |
| tokenFromNet in | |
| let storeLoginFuture = PKAccessTokenRepoFutures.storeToken(tokenFromNet, inRepo: tokenRepo) | |
| return storeLoginFuture | |
| }) | |
| .onSuccess(.main, block: | |
| { | |
| tokenFromDisk in | |
| let action = UpdateAccessTokenAction(accessToken: tokenFromDisk) | |
| reduxStore.dispatch(action) | |
| return tokenFromDisk | |
| }) | |
| .onFail(.main, block: | |
| { | |
| diskError in | |
| let action = LoginErrorAction(error: diskError) | |
| self.reduxStore.dispatch(action) | |
| return diskError | |
| }) | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I still had similar errors even without a
returnstatement.And this has solved my issue. Thanks a lot for responding so quickly.