如何从内置的流对象发出价值
我的问题是,我们如何从类似的构建流对象中发出值:
class Sample {
var flow: Flow<Object> = null
fun sendRequest(){
flow = flow{}
requestWrapper.flowResponse = flow
}
fun getResponse(){
// I want to emit data here with built flow object on
// requestWrapper like this
requestWrapper.flowResponse.emit()
}
}
对于此问题,是否有可能解决方案?
My question is that how we can emit a value from a built flow object like this:
class Sample {
var flow: Flow<Object> = null
fun sendRequest(){
flow = flow{}
requestWrapper.flowResponse = flow
}
fun getResponse(){
// I want to emit data here with built flow object on
// requestWrapper like this
requestWrapper.flowResponse.emit()
}
}
is any possible solution for this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
mutableSharedFlow
像在您的情况下一样发射值:You can use
MutableSharedFlow
to emit values like in your case: