5

To anyone with good knowledge of RxJs:

Should I be careful how many subscriptions I have open at a time? I'm specifically thinking about memory usage.

While obviously it's more, does it make a huge impact on memory usage, if I have 20 subscriptions active, compared to 2?

Comments
  • 4
    Really it should be quite cheap, memory wise, to have lots of subscriptions in any observer system. I wouldn't worry about it being a bottle neck in your software.
  • 1
    @beegC0de oh great. Still pretty new to the observer pattern
  • 3
    @KasperNS adding a subscriber to an observable should be no more than storing a pointer to the subscriber
  • 2
    @beegC0de yeah that what also my theory, but I couldn't find anything about it anywhere :/
  • 0
    Unsubscribe from observables when you don’t need them anymore, it should be like:
    let subscription = someObservable.subscribe(...)
    ...
    subscription.unsubscribe()
Add Comment