2016-11-25 70 views
0

我翻譯一段代碼從swift2到迅速3. 我使用ReactiveCocoa和我以前的代碼是這樣的:ReactiveCocoa swift3遷移

API.signin(withEmail: emailTextField.text!, password: passwordTextField.text!) 
    .on(started: { 
      SVProgressHUD.show() 
     }, 
     failed: { [weak self] error in 
      if error == .NotAuthorized { 
       self?.view.window?.dodo.error("Not authorized") 
      } else { 
       self?.view.window?.dodo.error("An error occured !") 
      } 
     }, 
     terminated: { 
      SVProgressHUD.dismiss() 
     }, 
     next: { [weak self] user in 
      print("user: \(user)") 
      UserService.userId = user.identifier 

      self?.emailTextField.text = nil 
      self?.passwordTextField.text = nil 
      self?.performSegueWithIdentifier(kRootSegueIdentifier, sender: self) 
     }) 
    .start() 

}

API.signin的類型是SignamProducer的 在新版本的ReactiveCoca中,似乎「下一個:」不再存在。我該怎麼辦 ?

回答

0

現在又成爲價值:像下面

SignalProducer<Int, NoError>(value: 1) 
     .on(value: { 
      print("value = \($0)") 
     }) 
     .start() 
+0

THKS。所以你不再有下一個:它已被替換爲值: – user3239711