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
3
votes
1 answer

Wait for subscription to complete

I have a simple scenario: I want to store an array returned from a service into a class variable. How do I wait for the data to be available until I store the data? It is available if I wait a certain amount of time (tested with settimeout)…
jibjapda
  • 87
  • 2
  • 2
  • 9
3
votes
1 answer

Observable http service

I'm 9 hours a day on Angular trying to make some little projects mainly with services. Today, I'm trying to make a service that loops on data's fetching and the components update themselves according to new data. I've like 6 components using the…
Jérémy JOKE
  • 271
  • 4
  • 15
3
votes
2 answers

Async Pipe Not Handling Subscription as Expected in Angular 2 App

I have been successfully using Observables throughout my Angular app. Up until now I've been explicitly subscribing in the component, and then using *ngFor to iterate over an array of records in the view. Now I'd like to simplify things by using…
Muirik
  • 6,049
  • 7
  • 58
  • 116
3
votes
1 answer

angular2 http request and websocket

Hi all I've an application that until now was only doing http request to retrieve data...now the problem is that we have also a websocket but I've no idea how to combine both of them: This is my http request: public stock(): Observable { …
d.zurico
  • 89
  • 7
3
votes
1 answer

How to do a simple notification system with redux-observable?

I'm trying to do a simple notification system with redux-observable. I'm new to rxjs so I'm having a hard time doing it. What I'm trying to do is: Dispatch an intent to display a notification Detect the intent with an Epic Dispatch the action that…
Mathius17
  • 2,412
  • 2
  • 21
  • 33
3
votes
1 answer

Can someone explain the Angular subscribe method

I am just learning Angular by reading tutorial for for v.4.0. I just got to the Section 6 (Routing) of that tutorial and I got stuck on understanding the subscribe method. I would be gratefull for some more explanation on it. I understand that…
an0o0nym
  • 1,456
  • 16
  • 33
3
votes
1 answer

How to animate the on enter and on leave of an updating Observable's values in an Angular+ template binding?

Plnkr: https://plnkr.co/edit/ka6ewGPo1tgnOjRzYr3R?p=preview I have a subscription that will change overtime: ngOnInit(){ this.route.snapshot.data.remote.subscribe(x => { this.obs$ = x[0]; }); } I have a template…
Armeen Moon
  • 18,061
  • 35
  • 120
  • 233
3
votes
2 answers

Observable determine if subscriber function has finished

What is the best way to determine if the subscriber has finished executing or better yet return something and catch it up-stream? For example: this._subscriptions.push(this._client .getCommandStream(this._command) // Returns an…
Arijoon
  • 2,184
  • 3
  • 24
  • 32
3
votes
0 answers

Observable creates infinite loop when http request fails

I use Observable in my Angular 4 application to load data from a web api. Have a service that looks like this: import { Injectable, Output, EventEmitter } from '@angular/core'; import { Http } from '@angular/http'; @Injectable() export class…
Burjua
  • 12,506
  • 27
  • 80
  • 111
3
votes
2 answers

Observable error handling by Angular's ExceptionHandler

I would like Angular's ExceptionHandler to handle any errors that occur from API calls. The problem is they never reach the ExceptionHandler's handleError method and I'm not sure what I need to do different. // data.service.ts addItem(name:…
user895400
  • 368
  • 1
  • 7
  • 18
3
votes
2 answers

How can I get the first async response fastest (and don't perform the remainder)?

Here's the setup: There is a federal remote service which returns whether a particular value is correct or not correct. We can send requests as we like, up to 50 per request to the remote service. Since we need to only use the correct value, and the…
djbyter
  • 763
  • 8
  • 28
3
votes
1 answer

Binding an element to a BehaviorSubject in an Angular service

I have a small shared Angular service which looks as follows: import {Injectable} from '@angular/core'; import {BehaviorSubject, Observable} from 'rxjs/Rx'; @Injectable() export class SidebarService { private _isOpen: BehaviorSubject =…
josef.van.niekerk
  • 11,941
  • 20
  • 97
  • 157
3
votes
0 answers

Pipe with Observable

I'm trying to create Pipe Which should send a request to the server, wait for an answer, and return the result import {Pipe, PipeTransform, Inject} from "@angular/core"; import {translationService} from "./translation.service"; @Pipe({name:…
Ashot
  • 245
  • 6
  • 16
3
votes
1 answer

How do I assert that an Observable doesn't push any item?

I would like to know how to unit test sequences like Observable.Never. How can I be sure that nothing will be pushed to the sequence?
SuperJMN
  • 13,110
  • 16
  • 86
  • 185
3
votes
7 answers

Unable to import 'Rx' to my Angular 2 application

I am pretty new at Angular2. I am trying to learn it using a dummy app. I have recently gone through a tutorial on RxJS and got a basic hold on Observables (or atleast I assume so). Based on that, I have an idea of returning a list of users from my…
Saurabh Tiwari
  • 4,632
  • 9
  • 42
  • 82