observable

Angular 2 change detection with observables

吃可爱长大的小学妹 提交于 2019-12-29 07:45:34
问题 I usually manage to find what I'm doing wrong just browsing existing questions, but here, nothing has helped. I'm working with a simple Ng2 module that attempts to list and update the contents of a NeDB store. Mind you, I have no issues with the NeDB store, I have confirmed that it gets updated correctly, and correctly loaded initially, so the problems I have lie elsewhere. The problems I have are the following: "the async pipe doesn't work". I have this module. @NgModule({ imports:

rxjava merge observables of different type

给你一囗甜甜゛ 提交于 2019-12-29 04:27:08
问题 I'm new to rxjava. I need to combine two observables that emit objects of different type. Something like Observable<Milk> and Observable<Cereals> and get a Observable<CerealsWithMilk> . I couldn't find any operator for something like this. What would be the rx way of doing something like this? Note that Milk and Cereals are async. 回答1: It's hard to say without knowing exactly what you need, but possibly zip() or combineLatest(). zip will take both Observable<Milk> and Observable<Cereals> and

RxJs Array of Observable to Array

痴心易碎 提交于 2019-12-28 16:30:24
问题 For a Web-Application written with Angular2 in TypeScript, I need to work with RxJs Observable s. As I never used rxjs before and I am new to reactiveprogramming in general, I sometimes have some difficulties finding the right way to do some specific things. I am now facing a problem. where I have to convert an Array<Observable<T>> into an Observable<Array<T>> . I'll try to explain it with an example: - I have an Observable , which gives me a list of Users ( Observable<Array<User>> ) - The

How to release memory of the responseText in an endless streaming request?

纵饮孤独 提交于 2019-12-25 16:57:56
问题 I need to use xmlHTTPRequest to fetch data from an endless motion JPEG data stream, and I heard that a nice trick that the responseText can populate data without finishing the request (it will never finish). Now I run into problem. My request is bind with RxJS observable like this. postActionGivenDataBinaryStream(url:string, data:string) : Observable<any>{ this.binary_progress_call_accum = 0 ; this.previous_length = 0 ; return Observable.create((observer)=>{ let xhr = new XMLHttpRequest() ;

How to call a function on a child component only when the parent component returns an observable using Angular4

岁酱吖の 提交于 2019-12-25 09:48:14
问题 "In a nutshell: make one HTTP request and pass that data to all components. The issue is that the other components run before I get the response back from the initial HTTP request. All components are just extracting bits of data from the HTTP response object" - Using Angular 4. Any help would be greatly appreciated, thank you. Basically, my parent component calls a service that loads my JSON. within the service method, I assign the response from my HTTP request to an Observable using rxjs

Angular2 - nested http requests

感情迁移 提交于 2019-12-25 04:18:12
问题 I have some component code that looks like this: private myThing: MyThing; ngOnInit() { this.service.getMyThing().subscribe(thing => { this.myThing = thing; } } However, the service looks like this - it is composed of data joined by two http requests. The first one is from "otherService", which fetches an additional property for the thing object, and the second call fetches the base thing object. I would like to combine these results and alert the subscriber when all action has been completed

Observable java object doesnt update

我的梦境 提交于 2019-12-25 04:17:06
问题 this is my ActivityA: public class ActivityA extends AppCompatActivity implement Observer { private Mouse _mouse; @Override protected void onCreate(Bundle savedInstanceState) { ... _mouse = new Mouse(); _mouse.posX = 30; _mouse.addObserver(this); } @Override public void onClick(View v) { Intent intent = new Intent(ActivityA.this, ActivityB.class); intent.putExtra("Mouse", Parcels.wrap(mouse)); startActivity(intent) } @Override public void update(Observable o, Object arg) { // Never get called

Rx SearchView needs to cancel on going request with less priority

孤街浪徒 提交于 2019-12-25 04:14:17
问题 I am using RxSearchView.queryTextChangeEvents to detect the events of “Search As You Type” and also when you submit a search, SAYT is to get suggestions and when you do a submit, it executes a full search. There are 2 problems I am having at the moment. When you are typing, and getting suggestions, but suddenly you click submit then it executes the full search but the problem is that if there is an on going suggestion request there might be the case that they appear on screen when they should

Shared Variable Used Globally in Angular 6 Components

荒凉一梦 提交于 2019-12-25 03:38:27
问题 I am working on Angular6 todo list task app. I have tasks categories when click on category I get this category's tasks it working with me well but I need to set categories in nav-component like image below. so I need store selected category id in value to use it in todo-component any help ..? 回答1: I found a way to make a shareable Object : create new service called GlobaleVariable.ts and write this on it : @Injectable() export class GlobalVariblesClass { sharedCategory$ = new ReplaySubject

async pipe into src image attribute - Angular 2+

假装没事ソ 提交于 2019-12-25 03:17:57
问题 i have problem with observable and async pipe. I have input in my component with Observable. In controller and on subscribe into observable in ngOnInit im get valid values. Problem is in template, I do not get valid values on template. I want to have async in image src attribute. TvShowComponent (return Observable) public getCoverLink(): Observable<string> { return this.tvShowForm.get('cover').valueChanges.pipe(map((coverLink: string) => { return coverLink; })); } TvShowComponent template