question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typeahead modifies Observable prototype

See original GitHub issue

Bug description:

The current code modifies the prototype of Observable in the typeahead component using statements like here:

https://github.com/ng-bootstrap/ng-bootstrap/blob/cfbc24a020d17b17181e684575df915d82e44a26/src/typeahead/typeahead.ts#L21

import 'rxjs/add/observable/fromEvent';

This is bad for several reasons. The consuming application is not aware of what is imported where and under which conditions. Also it constitutes a side effect which is generally to be avoided. The right way to do it is to import the operator as a function and use it standalone (e.g. map.call(myObservable, ...)), passing the Observable as an argument. An example can be found in the Angular code base:

https://github.com/angular/angular/blob/master/modules/%40angular/router/src/router.ts#L20

https://github.com/angular/angular/blob/master/modules/%40angular/router/src/router.ts#L685

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
DzmitryShylovichcommented, Jan 23, 2017

The fix is very simple and ng-bootstrap only has it in one component so if you prefer I could try my luck with a PR…

it’s not true https://github.com/ng-bootstrap/ng-bootstrap/search?utf8=✓&q=rxjs%2Fadd%2Fobservable

0reactions
DzmitryShylovichcommented, Jan 25, 2017

@blesh thx 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

rxjs - Rewriting observable sequence to make more sense
I'm creating a typeahead that remotely calls an api every time someone types in the input, with a small delay after typing. This...
Read more >
Version Pinning for Notebooks / Fabian Iwand / Observable
Observable supports version pinning by appending the version number to the notebook name or path. These functions make it easier to look up...
Read more >
Typeahead - Observable Hooks
React hooks for RxJS Observables. Simple, flexible, testable and performant.
Read more >
RxJS Autocomplete example - Unsaved project - Plunker
##RxJS Autocomplete example ###Example to show combining input events such as keyup ... Object.create(Error.prototype); ObjectDisposedError.prototype.name ...
Read more >
Safari Technology Preview Release Notes - Apple Developer
Accelerated Array.prototype.slice on DirectArguments (256027@main) ... Changed CSS autocomplete so that the most commonly used property accounts for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found