@@ -86,8 +86,8 @@ With this statement, the side effects and the memory leak are avoided.
8686
8787### Summary
8888__ ALWAYS unsubscribe if the observable does not complete or if you are not sure if it completes,
89- when using 1. code with side effects or 2. accessing member variables in the callback. __
90-
89+ since the callback logic still runs in the background otherwise,
90+ possibly creating memory leaks and unwanted side effects. __
9191
9292## Observables that eventually complete
9393We created the component `` RxjsTimerComplete `` . It contains the following observable:
@@ -314,13 +314,16 @@ If the callback executes code with side effects you should always unsubscribe.
314314If the callback uses member variables from the component class there can be a memory leak when using observables that don't complete,
315315therefore you should unsubscribe in that case.
316316
317- | | Side effects | Memory leaks |
318- | ----------------------------------------| -----------------| --------------|
319- | _ Observables that don't complete_ | Possible(1) | Possible(2) |
320- | _ Observables that eventually complete_ | Possible(1) | No |
321- | _ Angular HttpClient_ | Possible(1) | No |
317+ Observables that don't complete should be cancelled (almost) always,
318+ since the callback logic still runs (infinitely) in the background otherwise.
319+
320+ | | Side effects | Memory leaks | Should unsubscribe |
321+ | ----------------------------------------| -----------------| --------------| --------------------|
322+ | _ Observables that don't complete_ | Possible(1) | Possible(2) | Yes |
323+ | _ Observables that eventually complete_ | Possible(1) | No | Depends(1) |
324+ | _ Angular HttpClient_ | Possible(1) | No | Depends(1) |
322325
323- Possible(1): If you execute methods with side effects in the callback.
326+ Possible(1) / Depends(1) : If you execute methods with side effects in the callback.
324327
325328Possible(2): If you use member variables from the component in the callback.
326329
0 commit comments