【发布时间】:2021-01-12 20:51:47
【问题描述】:
我是 Combine 和 Sink 的新手,但是我放入其中的打印似乎没有记录,但是操作的结果在 AWS Amplify 中创建用户时完成。
@objc private func createAccountButtonAction(sender: UIButton) {
print("Create Account Button Action")
signUp(password: self.password, email: self.email)
}
func signUp(password: String, email: String) -> AnyCancellable {
let userAttributes = [AuthUserAttribute(.email, value: email)]
let options = AuthSignUpRequest.Options(userAttributes: userAttributes)
let sink = Amplify.Auth.signUp(username: email, password: password, options: options)
.resultPublisher.sink(receiveCompletion: { (authError) in
print("Failed with error: \(authError)")
}, receiveValue: { (signUpResult) in
print("Signed Up")
})
return sink
}
【问题讨论】:
-
不,我不明白。您返回一个名为
sink的组合管道,但您从不使用它做任何事情。你的意思是store它在某个地方吗?如果你不这样做,你的组合管道永远不会运行;它会立即死亡。 -
@matt,哦,这解释了为什么我看不到打印结果,但是我只遵循 AWS Amplify 教程,它不知道如何使用这些功能 :( 但是谢谢你,我会去探索水槽和商店
-
我对 Amplify 对 Combine 的支持一无所知。我只是在评论返回管道然后将其丢弃的不连贯性。有关一些实际工作示例,请参阅我的 apeth.com/UnderstandingCombine/start/startpipelines.html。
-
现在遇到同样的问题!这些帖子很有帮助。 Amplify 文档通常很棒,但似乎暗示了对 Combine 框架的先验知识。谢谢大家。
标签: swift aws-amplify combine