Rxjs Subject next() after complete()

我的未来我决定 提交于 2019-12-08 19:08:36

问题


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.

I wanted to know, can we still pass Subject observables still next(newData) if once completed() is already been triggered?


回答1:


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:

  • decide not to complete the subject (why indeed are you completing it if you still need it later on?)
  • create a new subject whenever you need one, but then you have to pass it to whoever needs it.


来源:https://stackoverflow.com/questions/35850409/rxjs-subject-next-after-complete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!