Do I need to free/release Observable object after I use it?

后端 未结 2 1078
终归单人心
终归单人心 2021-01-27 10:55

Do I need to free/release Observable object after I use it in case Observable object is not garbaged by GC? I didn\'t find any article to mention it. Is Observable object garbag

2条回答
  •  梦毁少年i
    2021-01-27 11:05

    In most cases we will not need to explicitly call the unsubscribe method unless we want to cancel early or our Observable has a longer lifespan than our subscription. The default behavior of Observable operators is to dispose of the subscription as soon as .complete() or .error() messages are published. Keep in mind that RxJS was designed to be used in a "fire and forget" fashion most of the time. read

提交回复
热议问题