Skip to content

Instantly share code, notes, and snippets.

@andreyfomenkov
Last active December 20, 2020 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreyfomenkov/1e02ba9693a3f9b0850b446c1eb717f9 to your computer and use it in GitHub Desktop.
Save andreyfomenkov/1e02ba9693a3f9b0850b446c1eb717f9 to your computer and use it in GitHub Desktop.
Now OK
class WeatherActivity : AppCompatActivity() {
private val thermometer = Thermometer.getInstance()
private var disposable: Disposable? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
disposable = thermometer // Save the result of subscribe() method
.observeTemperature()
.subscribe { celsius -> /* Display in a TextView */ }
}
override fun onDestroy() {
disposable?.dispose() // Do not forget to dispose a resource!
super.onDestroy()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment