Is using weak links in Observers a good idea?

I implemented the Observable class, which stores a list of all observers. Should this list contain weak references to observers to prevent memory leaks?

What is common practice?

+3
source share
2 answers

Not necessarily, it depends on the context. Some observers may simply want to do simple things, such as logging, etc., and would rather stay alive with an Observable. It is best to do this in order to clearly document your choice, so that observers know if they need to explicitly allow themselves.

+1
source

, Rx, IObservable .NET 4, Subscribe Subject, . On* .

, , . , , Subscribe, Rx (, Take TakeUntil).

0

Source: https://habr.com/ru/post/1792520/


All Articles