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

How to make async data observable?

New to observables. I'm using ssh2 to get a list of files/folders on my server. I can't figure out how to get my data back as an observable since all of the examples of online use http rather than a 3rd party module. How can I set this service up…
Justin Young
  • 2,393
  • 3
  • 36
  • 62
3
votes
1 answer

Avoid recursion with RxJS5 observables

Okay, so I would like to avoid recursion with observables, using a combination of external and internal events instead of recalling the same method/function. Right now I have this: Queue.prototype.deq = function (opts) { opts = opts || {}; …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
3
votes
1 answer

understanding observers and subscibers angular2

long time lurker - first time poster. This is a lot of theory, so bear with me. I am working to mentally model the idea of an observable, observer and a subscriber (rxjs and angular2) and wanted to make sure I am on the right track. I currently…
Nathan King
  • 45
  • 1
  • 5
3
votes
1 answer

Rendering edit forms in angular2. How can I wait for data from service?

I tried to render form for editing with data from service and I got an error because my initForm() method calls before I get data from service. How can I fix it? My component import { Component, OnInit } from '@angular/core'; import { Subscription }…
3
votes
1 answer

How to create Observable from Subject without exposing the Subject to consumers in RxJs v5

I'm trying to return an observable from a function that uses Rx.Subject internally. Of course, as with any good API, the implementation details should be entirely abstracted from the consumer. However, using Subject.asObservable() it appears…
Adam Arthur
  • 409
  • 3
  • 10
3
votes
1 answer

Android/RxJava, prevent multiple subscriptions of the same kind

Good morning, I am recently taken up playing around with RxJava and I am facing a problem. I have a Fragment in a ViewPager which on onViewCreated() launches an HTTP request (handled by Retrofit and RxJava) to retrieve a list of Strings. The way it…
kioli
  • 635
  • 1
  • 10
  • 26
3
votes
1 answer

Angular 2 - Typescript: TS2322: Type 'Subscription' is not assignable to type 'Observable'

I am using the click-outside directive from this plunk --> http://embed.plnkr.co/v7BMUv/ My TS compiler is throwing the following errors: TS2322: Type 'Subscription' is not assignable to type 'Observable'. Property '_isScalar' is missing in type…
Shilpa Nagavara
  • 1,055
  • 2
  • 16
  • 31
3
votes
1 answer

In MVP pattern how to access specified view component in Presenter?

SignUpFragment uses SignUpPresenter and SignUpFragment inplements SignUpView. SingUpPresenter extends BasePresenter where BasePresenter: public abstract class BasePresenter { private WeakReference mView; public void bindView(@NonNull V…
I.S
  • 1,904
  • 2
  • 25
  • 48
3
votes
2 answers

What is analogous to Promise.resolve for an Observable?

Here's an example of some code I picked up for an Angular2 tutorial by Max Schwarzmueller on YouTube: https://www.youtube.com/playlist?list=PL55RiY5tL51olfU2IEqr455EYLkrhmh3n. import {Injectable} from "angular2/core"; import {CONTACTS} from…
BBaysinger
  • 6,614
  • 13
  • 63
  • 132
3
votes
2 answers

Pass more values to subscribe function of an observables

I would like to convert and replace all words in an array using a an object's method which returns an observable. The problem is that since the result is asynchronous, the value of result is overwritten incorrectly at the wrong index. If I had a…
Ari
  • 7,251
  • 11
  • 40
  • 70
3
votes
1 answer

Angular2 trigger function when observable property changes

I use a workingData service that holds data that permeates my application. It returns an observable to the Mock workingData object. @Injectable() export class WorkingDataService { getWorkingData(): Observable { return…
3
votes
1 answer

How to call second observable only if first Observable returns null

suppose i have two methods which returns an observable method1(): Observable { returns data or null; } method2(): Observable { always returns data; } Now i call method1 first, if this returns some data, then don't call method2,…
chandradot99
  • 3,616
  • 6
  • 27
  • 45
3
votes
1 answer

how to abort and "resolve" a subscription immediately in rxjs?

New to rxjs and angular2. How do I abort an http call and return an observable so I don't get an error on the subscription end? of course if I just return an object here, we get .searchAlbum(...).subscribe is not a function public searchAlbum…
FlavorScape
  • 13,301
  • 12
  • 75
  • 117
3
votes
1 answer

Angular2: Set CSS class from Observable

There are actually two challenges I face. I am looping through an array of values and need to set a class name depending on an observable variable from a child component. reevaluate the class as soon as the child variable…
pop
  • 3,464
  • 3
  • 26
  • 43
3
votes
1 answer

Observable event limit/keep only one event in memory/backpressure

I have subscribed to timer that produces event every n seconds Observable.interval(1000) .startWith(0) .map( x => { return 'USER'; } i have also other observable, that produces results that are not available from the very…
charlie_pl
  • 2,898
  • 4
  • 25
  • 39