staltz / xstream

An extremely intuitive, small, and fast functional reactive stream library for JavaScript
http://staltz.github.io/xstream/
MIT License
2.37k stars 137 forks source link

subscribe's argument should support Partial<Listener> #241

Closed janckerchen closed 6 years ago

janckerchen commented 6 years ago

It's very often to subscribe with empty listener, like

xs.periodic(1000).subscribe()

It's unnecessary to repeat this everytime, in typescript of couse

xs.periodic(1000).subscribe({next(){}, error(){}, complete(){}})
mightyiam commented 6 years ago

You'd never wish to do that, other than debugging, I figure. So maybe it's fine as it is?

staltz commented 6 years ago

In JavaScript, .subscribe({}) should work. In TypeScript, I think it's a bug that it doesn't support {}, because the argument should be Listener, but under the hood, subscribe uses addListener, which in TypeScript correctly supports a Partial<Listener>.

xtianjohns commented 6 years ago

.subscribe({}) works just fine for me in JS/TS in 11.7. Should we close?