Skip to content

trying to use rxjs - getting vendor/rxjs/index.js 404 (Not Found) in browser #730

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

Closed
alvipeo opened this issue May 11, 2016 · 6 comments
Closed

Comments

@alvipeo
Copy link

alvipeo commented May 11, 2016

Added to my prj jquery, bootstrap 4, other things and got it working (except for tests - a separate issue). Now, trying to add some state which uses rxjs (Observables, etc) and now getting in a browser (in Chrome, when 'ng serve'):

zone.js:101 GET http://localhost:4200/vendor/rxjs/index.js 404 (Not Found)

Why is it looking for rxjs/index.js ???

Here's now I added it - folder structure first:

  • app
    • shared
      -models added
      • news.model.ts - simple class for model
      • index.ts - (export * from "./news.model";)
  • state added
    • appState.ts - contains actual code that uses rxjs
    • index.ts - (export * from "./appState";)

and then I just use it in my main component - with import from ... and DI.

Example code for appState.ts:

import { Observable, BehaviorSubject } from "rxjs";
import { NewsItem } from "../models";

export interface AppState {
    news: NewsItem[];
}

export class AddNewsAction {
    constructor(public newItem: NewsItem) { }
}

export type Action = AddNewsAction;

export function stateFn(initState: AppState, actions: Observable<Action>): Observable<AppState> {
    const combine = s => ({ news: s[0] });
    const appStateObs: Observable<AppState> = allState(initState.news, actions)
        .map(combine);

    return wrapIntoBehavior(initState, appStateObs);
}

...

@alvipeo
Copy link
Author

alvipeo commented May 11, 2016

Can't really format lists on github, so for clarity - the folder structure:
;; app
;; ;; shared
;; ;; ;; models
;; ;; ;; state

@alvipeo
Copy link
Author

alvipeo commented May 11, 2016

The project zip.

Feel free to download.

Should I

import { Observable } from "rxjs/Observable";

and so on? I tried that but 1) it gets too verbose and 2) this

import { map } from "rxjs/operator/map";

does not help because I still get the error - map is not a func.

Finally, I tried to import from 'rxjs/Rx' but still getting error for map.

@BenevidesLecontes
Copy link

I'm using rxjs and it's working fine for me.
In my main component: import 'rxjs/Rx';
In my service import {Observable} from 'rxjs/Observable';

@alvipeo
Copy link
Author

alvipeo commented May 11, 2016

I think I found it... will post update later.

@alvipeo
Copy link
Author

alvipeo commented May 13, 2016

ok, while setting up injection I typed useValue instead of useFactory. My bad.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants