Skip to content

Commit 94cff32

Browse files
committed
Update readme
1 parent 7902e27 commit 94cff32

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
9393
We 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.
314314
If the callback uses member variables from the component class there can be a memory leak when using observables that don't complete,
315315
therefore 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

325328
Possible(2): If you use member variables from the component in the callback.
326329

0 commit comments

Comments
 (0)