Closed Jamesernator closed 7 years ago
Pretty sure bound functions are a no-no given how much people are focusing on performance.
There is nothing weird about the example above. resolve is a function, observer is an object. The expectation that methods on objects must be bound is well-established in JavaScript.
Bound observer methods would allow destructuring for really concise syntax. Here's a passThrough
operator written with destructuring:
const passThrough = (input, fn) =>
new Observable(({ next, error, complete }) =>
input.subscribe({
next: value => {
fn(value);
next(value);
},
error,
complete,
}),
);
and without:
const passThrough2 = (input, fn) =>
new Observable(observer =>
input.subscribe({
next(value) {
fn(value);
observer.next(value);
},
error(e) {
observer.error(e);
},
complete() {
observer.complete();
},
}),
);
Kindof nice. That said, if it's a performance issue it's a performance issue, I'd rather have performance than ultra concise syntax.
As the title says, it's a little weird that I can do:
but not: