user3239711
user3239711

Reputation: 649

ReactiveCocoa swift3 migration

I am translating a piece of code from swift2 to swift 3. I am using ReactiveCocoa and my old code is this :

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 is of type SignamProducer It seems the "next:" is no longer here in the new version of ReactiveCoca. What shall I do ?

Upvotes: 0

Views: 86

Answers (1)

alex_kael
alex_kael

Reputation: 61

now it becomes value: like below

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

Upvotes: 0

Related Questions