Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular reference between Observable and others #899

Closed
kwonoj opened this issue Dec 5, 2015 · 11 comments
Closed

Circular reference between Observable and others #899

kwonoj opened this issue Dec 5, 2015 · 11 comments
Labels
bug Confirmed bug

Comments

@kwonoj
Copy link
Member

kwonoj commented Dec 5, 2015

Observable.ts

...
import {ConnectableObservable} from './observable/ConnectableObservable';
import {Subject} from './Subject'; --> import subject

...
if (observerOrNext instanceof Subscriber || observerOrNext instanceof Subject) {

Subject.ts

...
import {Observer} from './Observer';
import {Observable} from './Observable'; --> import observable
...
export class Subject<T> extends Observable<T>
...

ends up with below snippet

import {Observable} from 'dist/cjs/Observable';

Observable.of(1).subscribe(console.log);
 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
                                                                   ^
TypeError: Cannot read property 'prototype' of undefined
    at __extends (D:\github\RxJS\dist\cjs\Subject.js:4:68)
    at D:\github\RxJS\dist\cjs\Subject.js:20:5
    at Object.<anonymous> (D:\github\RxJS\dist\cjs\Subject.js:135:3)

Subject does not resolves reference to Observable.

@kwonoj
Copy link
Member Author

kwonoj commented Dec 5, 2015

Not sure if #894 is related or not..

@benlesh
Copy link
Member

benlesh commented Dec 5, 2015

It's probably #894. TypeScript is pretty good about hoisting dependencies that would otherwise be circular.

import {Observable} from 'dist/cjs/Observable'; will just get you the bare-bones Observable without from and of right now.

@kwonoj
Copy link
Member Author

kwonoj commented Dec 5, 2015

Did couple of try, seems #894 and this need to be updated both. even import from / of to observable, importing observable directly would not work due to this.

@kwonoj kwonoj changed the title Circular reference between Observable and Subject Circular reference between Observable and others Dec 6, 2015
@kwonoj
Copy link
Member Author

kwonoj commented Dec 6, 2015

Changed subject to describe this more general, such as

  • Observable <--> GroupedObservable
  • Observable <--> CoreOperators <--> GroupedObservable ..(direction is not precise, just an example)

and lot of others.

This reference could possibly cause runtime reference resolve issue as described above and also noticeably increases build times.

Tried to solve this via simple ambient declaration but wasn't work as expected, ambient merging seems possible way but still need to prove.

@ntilwalli
Copy link
Contributor

@kwonoj Just a quick comment, dunno if it's relevant, I introduced this circular import with #863 and to deal with it I updated the KitchenSink and Rx files to move the Subject import before Observable. I made a comment to that effect in the discussion and in the checkin notes. Until I reordered these imports, I was seeing the same error.

@kwonoj
Copy link
Member Author

kwonoj commented Dec 7, 2015

@ntilwalli I assume top-level (Rx / Kitchensink) is also somewhat related, but not critical at this moment. This issue is specific for module-level import (i.e, import observable only, or something else) to make reference resolve failure to work with specific module. Once this is cleanly resolved, may able to visit top level module also using similar approaches.

@benlesh
Copy link
Member

benlesh commented Dec 7, 2015

@jeffbcross ran a circular dependency check on #912 and found it was green. So that PR is likely all we need to clear this issue.

Also, we're going to add some sort of circular dependency checking to the test build. (again, @jeffbcross)

@benlesh benlesh added the bug Confirmed bug label Dec 7, 2015
@jeffbcross
Copy link
Contributor

PR for ci check: #917

@kwonoj
Copy link
Member Author

kwonoj commented Dec 7, 2015

Cool news, then assume #909 can be close without merging? @Blesh

@benlesh
Copy link
Member

benlesh commented Dec 8, 2015

#912 closes this.

@benlesh benlesh closed this as completed Dec 8, 2015
@lock
Copy link

lock bot commented Jun 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants