Questions tagged [observable]

An observable is typically a programming construct that can be "watched" by other parts of the code, called the "observers". Different frameworks and programming languages have different implementations for observables, so this tag should typically be used in conjunction with others.

An observable is typically a programming construct that can be "watched" by other parts of the code, called the "observers". Different frameworks and programming languages have different implementations for observables, so this tag should typically be used in conjunction with others.

An observer may be any object that implements interface Observer. An observable object can have one or more observers. After an observable instance changes, an application calling the Observable's “notification” method causes all of its observers to be notified of the change by a call to their update method.

References

9527 questions
26
votes
2 answers

How to handle for promise inside a piped map

I am definitely sure I am confused here so please any help is appreciated. Here is my scenario: I pull from Firestore a document: return this.afs.collection("events").doc(eventID).snapshotChanges().pipe( map( document => { }) …
Jimmy Kane
  • 16,223
  • 11
  • 86
  • 117
26
votes
2 answers

What is the difference between ViewModel that extends BaseObservable and Android ViewModel Class?

I am currently studying about MVVM architectural pattern but I got confused between Custom ViewModel class that Extends BaseObservable and Another ViewModel which is provided by Android itself.
Urvish rana
  • 601
  • 10
  • 24
26
votes
12 answers

How to make countdown timer with RxJS Observables?

I'm struggling to create a countdown timer using Observables, the examples at http://reactivex.io/documentation/operators/timer.html do not seem to work. In this specific example the error related to timerInterval not being a function of the…
Jon Miles
  • 9,605
  • 11
  • 46
  • 66
25
votes
3 answers

RxJS5 finalize operator not called

I'm trying to trigger a callback when all my observables are executed. In my other, older project i used finally like so and that worked like a charm: this.myService.callDummy() .finally(() => console.log('Works!')) .subscribe(result =>…
Nico Van Belle
  • 4,911
  • 4
  • 32
  • 49
25
votes
3 answers

Putting two async subscriptions in one Angular *ngIf statement

I have the following in my component template:
Sammy
  • 3,395
  • 7
  • 49
  • 95
25
votes
2 answers

Angular 2 - subscribing to Observable.fromEvent error: "Invalid event target"

I am getting a weird error when trying to subscribe to an Observable. Here is a watered down version of the code which presents the problem: import {Component, Input, OnInit, ViewChild} from '@angular/core'; import Rx from…
deafdigit
  • 303
  • 1
  • 3
  • 5
25
votes
4 answers

Can I observe additions to an array with rx.js?

fromArray Rx wiki on github coffee> rext = require 'rx' coffee> arr = [1..5] [ 1, 2, 3, 4, 5 ] …
jcollum
  • 43,623
  • 55
  • 191
  • 321
25
votes
4 answers

Giving initial value to observable from the HTML markup

I'm trying to create an HtmlHelper extension that outputs some HTML to the view. In this HTML I'm wiring up some KnockoutJS binding. I'm new to KO so I'm still struggling in getting some things done. Anyway, what I'm trying to do is generate input…
Kassem
  • 8,116
  • 17
  • 75
  • 116
24
votes
6 answers

When to use Promise over observable?

Is there any case, where Promise is more powerful as compare to observable? I know a lot of benefits of observables over promises. But Is there any case, I should use only promises over observables. I found this link, promises vs observables. But…
Nimish goel
  • 2,561
  • 6
  • 27
  • 42
24
votes
1 answer

How to rerun resolvers when queryParams change

I'm working on it for days, But doesn't find any solution so far. I've got a resolver service, which's supposed to return an Observable : resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) : Observable|Promise{ return…
KCarnaille
  • 1,027
  • 9
  • 18
24
votes
1 answer

How to bind ngclass to an observable value

Is binding to an Observable possible like this in Angular? or where mapToolBarMode$ is the observable It…
jenson-button-event
  • 18,101
  • 11
  • 89
  • 155
24
votes
1 answer

How to find an element of an array by id with Observable in Angular2

I decided to use Observable instead of Http promises. That is how my Promise service looked: export class MovieService { movies: Movie[] movie: Movie; constructor(private http:Http) { } getMovies(): Promise{ return…
GaborH
  • 689
  • 2
  • 11
  • 24
24
votes
2 answers

q.all for angular2 observables

is there something like q.all to resolve all http api requests in angular2? In angular1, I can do something like this: var promises = [api.getA(),api.getB()]; $q.all(promises).then(function(response){ // response[0] --> A // response[1] …
kdu
  • 1,259
  • 4
  • 12
  • 18
24
votes
4 answers

Handle Network error with Retrofit observable

When using Observables with Retrofit how do you handle Network failure? Given this code: Observable observable = api.getApiService().getMyData(); observable .doOnNext(new Action1() { @Override …
Patrick Jackson
  • 18,766
  • 22
  • 81
  • 141
23
votes
5 answers

How to cancel/revert changes to an observable model (or replace model in array with untouched copy)

I have a viewModel with an observableArray of objects with observable variables. My template shows the data with an edit button that hides the display elements and shows input elements with the values bound. You can start editing the data and then…
Damien Gabrielson
  • 596
  • 2
  • 5
  • 11