Angular/RxJs When should I unsubscribe from `Subscription`

前端 未结 22 2206
隐瞒了意图╮
隐瞒了意图╮ 2020-11-21 04:56

When should I store the Subscription instances and invoke unsubscribe() during the NgOnDestroy life cycle and when can I simply ignore them?

22条回答
  •  不知归路
    2020-11-21 05:19

    The SubSink package, an easy and consistent solution for unsubscribing

    As nobody else has mentioned it, I want to recommend the Subsink package created by Ward Bell: https://github.com/wardbell/subsink#readme.

    I have been using it on a project were we are several developers all using it. It helps a lot to have a consistent way that works in every situation.

提交回复
热议问题