angular


Angular 2 RxJS Observable not loading


my web application breaks (won't load) when I use 'new Observable()' anywhere in a method or otherwise.
Angular version 2.1.0
RxJs 5.0.0-beta.12
These are my imports in the .ts-file:
import { Injectable } from '#angular/core';
import { DSUnit } from '../model/dsunit';
import { Headers, Http, Response } from '#angular/http';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/throw';
import 'rxjs/Rx';
import { DSCategory } from './../model/dscategory';
import { Observable } from 'rxjs';
When I have this piece of code it breaks:
private handleError(error: any) : Observable<any> {
let errMsg = "argh";
return new Observable(); // <-- "offending" code
}
with this error on the console of Chrome:
(SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/rxjs(…)
And when I remove the offending line, and have this instead:
private handleError(error: any) : Observable<any> {
let errMsg = "argh";
return null; // <-- "works"
}
my web application loads with no errors.. of course it breaks when the 'catch'-statement tries to handle an error, but that will work once I get past the hurdle with
"new Observable()"
Any ideas, anyone?
You could try this:
Observable.of(errMsg);
or
Observable.throw(errMsg);
depending on the caller.
Damn it... the 'auto import' in Visual Studio Code had messed up my import.
When I import '{Observable}' it should not be
import {Observable} from 'rxjs'
it should be
import {Observable} from 'rxjs/Rx'

Related Links

cannot find module errors after upgrading to angular-2.0.0-rc.4
Angular 2 don't dectect change on an Observable
Convert date in format accepted by restService
Reset forms in Angular2
Angular 2 - App Component Protect
GetSentry RavenJS not importing in webpack build
Wait for Angular 2 to load/resolve FormBuilder/ControlGroups before rendering view/template
Angular2 CanActivate from beta to current RC3
Rxjs: Why this stream of array not recieving new values
Page transitions in Angular 2
Base64 image with charset=utf-8; not displayed in Ionic2
Getting a wrong object through behavior suject
How to create complex(nested) JSON object in typescript in Angular2
Angular2 Router 3.0 beta 1 ( Child routes via Routerlink failed)
Angular2 AfterViewChecked not firing on a directive when binding is complete on RC4
angular 2 - click function not working inside the popover

Categories

HOME
processing
scadalts
asynchronous
screensaver
netlogo
soap
modularity
basecamp
luigi
keen-io
maven-lifecycle
speech-recognition
etcd
google-places-api
timezone
postgis
spark-dataframe
jestjs
visio
ninja
affinity
shogun
video.js
jxmaps
rinsim
android-constraintlayout
derivative
spring-statemachine
google-nativeclient
silex
face-api
pex
oracle-data-integrator
chinese-locale
uilabel
c#-to-f#
grunt-connect-proxy
kinvey
multiple-domains
rcp
street-address
uwamp
citations
sqlcmd
data-compression
enzyme
uievent
data-processing
pwd
preferencefragment
matlab-guide
jedi-vim
c++1z
crypto++
android-build
miva
jquery-events
sqlcommand
munin
rpy2
audio-player
rpath
motorola
windows-firewall-api
dde
display-bugs
nokia
little-endian
arrangeoverride
ibm-jazz
r1soft
spsite
adobe-flash-cs3
fedora-commons
ti-nspire
pull-request
fluid-layout
.a
eazfuscator
navigationbar
virtual-address-space
mysql-error-1093
stackato
syntactic-sugar
policies
svggraph
maptiler
android-3.0-honeycomb
hierarchyid
stackmob
perl-critic
sniffing
maskedinput
file-association
opengl-es-1.1
icarousel
alpha-five
objectiveflickr
utl-file
nested-queries
osx-gatekeeper
in-app
windows-networking
statusnet
bootclasspath
django-generic-views
equivalent
xml-comments
showmodaldialog

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App