Why have a $subscribeTo ?
kevupton opened this issue · 1 comments
kevupton commented
https://github.com/vuejs/vue-rx/blob/master/src/methods/subscribeTo.js
Original Code:
export default function subscribeTo (observable, ...subscribeArgs) {
const subscription = observable.subscribe(...subscribeArgs)
;(this._subscription || (this._subscription = new Subscription())).add(subscription)
return subscription
}
I would recommend this approach instead:
export default function addSubscription (subscription) {
;(this._subscription || (this._subscription = new Subscription())).add(subscription)
}
It is simpler, cleaner a nicer way to not abstract logic away.
Then you can leave the subscribing elsewhere.
regou commented
Some may just use native subscribe and then see the program works fine so forget to unsubscribe.
subscribeTo
Implied that if full embrace the library, the library itself will take care everything
addSubscription
didn't show that kind of sense
Why add ? Add to where? For what?
Or maybe call it addAutoUnsubSubscription
?