All Questions

24
votes
4answers
5750 views

How do I return the response from an Observable/http/async call in angular2?

I have service which returns an observable which does an http request to my server and gets the data. I want to use this data but I always end up getting undefined. What's the problem? Service: @Inj...
137
votes
6answers
74469 views

Delegation: EventEmitter or Observable in Angular

I am trying to implement something like a delegation pattern in Angular. When the user clicks on a nav-item, I would like to call a function which then emits an event which should in turn be handled ...
288
votes
11answers
61792 views

Angular/RxJs When should I unsubscribe from `Subscription`

When should I store the Subscription instances and invoke unsubscribe() during the NgOnDestroy life cycle and when can I simply ignore them? Saving all subscriptions introduces a lot of mess into com...
33
votes
3answers
61745 views

Observable type error: cannot read property of undefined

Angular 2 application, I get an error: cannot read property 'title' of undefined. This is a very simple component, just trying to get a bare minimum to work here. It hit's my API controller (curious...
16
votes
2answers
18955 views

Angular 2 - Return data directly from an Observable

I've been banging my head against this one trying to figure it out, and no amount of documentation I've been able to read has given me an answer to my question. I have a service which is speaking dir...
147
votes
10answers
111628 views

When should we use Observer and Observable

An interviewer asked me: What is Observer and Observable and when should we use them? I wasn't aware of these terms, so when I came back to home and I started Googling about Observer and Observable ...
69
votes
4answers
107523 views

How to catch exception correctly from http.request()?

Part of my code: import {Injectable} from 'angular2/core'; import {Http, Headers, Request, Response} from 'angular2/http'; import {Observable} from 'rxjs/Observable'; import 'rxjs/add/operator/map';...
48
votes
2answers
8339 views

Why is java.util.Observable not an abstract class?

I just noticed that java.util.Observable is a concrete class. Since the purpose of Observable is to be extended, this seems rather odd to me. Is there a reason why it was implemented this way? I foun...
60
votes
7answers
79848 views

Wait for Angular 2 to load/resolve model before rendering view/template

In Angular 1.x, UI-Router was my primary tool for this. By returning a promise for "resolve" values, the router would simply wait for the promise to complete before rendering directives. Alternately,...
3
votes
1answers
1452 views

Leveraging the observer pattern in JavaFX GUI design

As noted here in the context of Swing, GUI design makes frequent use of the observer pattern. Having frequently used the scheme prescribed in EventListenerList, is there a Java FX example, such as Con...

Previous Next