javascript: pattern to cancel subscription of RxJS subscriptions

I was reading Ben Lesh's article here:
https://medium.com/@benlesh/rxjs-dont-unsubscribe-6753ed4fda87

I wonder: is the following pattern enough?
https://gist.github.com/ORESoftware/fc1adbe6babd0bba13365ee194c78a6b

Component export class {

mounted = true;
constructor (private s: MyService) {}

onMount () {

this.s.obs.takeWhile (makePredicate ()). subscribe (...)

}

makePredicate () {
return () => this.mounted;
}

onDismount () {
this.mounted = false;
}


}

There may be an internal Boolean to which I can refer, so I may not even have to use my own Boolean, although internal APIs may change, so it's probably better to have my own Boolean.

Note that the previous example is an agnostic code (do not Angluar or React in particular)