egramtel / egram.tel

Crossplatform Telegram client
https://egram.tel
MIT License
367 stars 71 forks source link

Prefer WhenActivated over IDisposable #16

Closed worldbeater closed 5 years ago

worldbeater commented 6 years ago

ReactiveUI guidelines recommend using WhenActivated to control the lifecycle of a ViewModel. Let's prefer it over bare metal IDisposables.

WhenActivated is a way to track disposables. Besides that, it can be used to defer the setup of a ViewModel until it's truly required. WhenActivated also gives us an ability to start or stop reacting to hot observables, like a background task that periodically pings a network endpoint or an observable updating users current location.

Docs: https://reactiveui.net/docs/handbook/when-activated/ https://github.com/AvaloniaUI/Avalonia/pull/1951

x2bool commented 5 years ago

Done!

worldbeater commented 5 years ago