问题描述
我有与 Subject()
连接的服务来进行分页.我正在使用 next(newData)
传递给主题,这使事情保持活力,现在我需要在每个 ajax 调用中使用 complete()
并将其传递给主题.但是在做了一个 complete()
之后,我开始出现错误.
I have service which connects with Subject()
to do paging. I'm using next(newData)
to pass to subject, which keeps things alive, now I need to use complete()
on each ajax call and pass it to subject. but after doing one complete()
I'm started get error.
我想知道,如果 completed()
已经被触发,我们是否仍然可以通过 Subject
observables 仍然 next(newData)
?
I wanted to know, can we still pass Subject
observables still next(newData)
if once completed()
is already been triggered?
推荐答案
有一些关于堆栈溢出问题的主题信息:这里.我鼓励您查看它.
There is some information on subjects from a former question on stack overflow : here. I encourage you to review it.
关于您的具体问题,主题一旦完成就不能再发出.这是他们遵守的合同的一部分.根据应用程序的逻辑和流程,您可能会:
About your specific question, subjects once completed cannot emit any longer. This is part of the contract they abide by. Depending on the logic and flow of your application, you might:
- 决定不完成该主题(如果您以后还需要它,为什么还要完成它?)
- 在您需要时创建一个新主题,但随后您必须将其传递给需要它的人.
这篇关于Rxjs 主题 next() 后 complete()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!