rxjs

RxJS Observables does not display data on subscribe or async

≯℡__Kan透↙ 提交于 2019-12-13 03:31:24
问题 I am trying to get all the data from firestore - collection and subcollection into an observable form of array and display it with async pipe. availableCategoriesCollection: AngularFirestoreCollection<Category>; availableCategories$: Observable<CategoryId[]>; lstCategories: Observable<any>; this.availableCategoriesCollection = this.httpDataService.getAllCategories(); this.availableCategories$ = this.availableCategoriesCollection.snapshotChanges().map(data => { return data.map(record => {

Websocket epic that receives connection & message requests and emits messages & connection status updates

南楼画角 提交于 2019-12-13 03:30:56
问题 I am hoping to create an redux-observable epic that can sit separate to the rest of my application. It needs to: Listen for incoming action of { type: "SOCKET_TRY_CONNECT" } , this should also probably disregard any additional SOCKET_TRY_CONNECT events while it is connected. Additionally listen for messages to be sent, maybe { type: "SOCKET_MESSAGE_SEND", data } Emit outgoing actions { type: "SOCKET_CONNECTED" } , { type: "SOCKET_DISCONNECTED", error } and { type: "SOCKET_MESSAGE_RECEIVE",

Nested Observable with unknown nesting depth

空扰寡人 提交于 2019-12-13 03:28:49
问题 When sending a Get request to Sharepoint URI (e.g. http://company.com.au/teams/Telstra/_api/web/Lists/getbytitle('${listTitle}')/items ), it returns a finite number of items (e.g. 30) and provides a link to query to retrieve the next 30 items like so: I am writing an Angular app to retrieve all items. The pseudo code is like so: public GetByDomainOwner(listTitle: string, domainNameOwner: string): Observable<any[]> { let dataToReturn = new Array<any>(); let URI = `http://company.com.au/teams

Need help on using takeUntil() and Observable.fromEvent() Methods

只谈情不闲聊 提交于 2019-12-13 03:14:58
问题 I'm following this tutorial to create Reactive TCP server in Nodejs here's code that i've been working on const Rx = require('rxjs') const net = require('net') const uuid = require('uuid'); module.exports = () => { const sockets = new Map(); const ids = new Map(); const GetSocket = _id => sockets.get(_id); const GetId = _socket => ids.get(_socket); const SetSocket = _socket =>{ _socket.setEncoding('utf8'); const _id = uuid(); sockets.set(_id, _socket); ids.set(_socket,_id); return _id; };

How to create an RxJS Observable such that it returns a value when call back function completes

落爺英雄遲暮 提交于 2019-12-13 03:11:48
问题 I need to create an RxJS Observable such that it returns a value when call back function completes. Below is the code, I have tried. I want to return 'resources' to be returned in the caller subscribing to loadMarkerImages function loadMarkerImages(markerNameAndImageUrlMap) { let loader = new PIXI.loaders.Loader(); for (let markerKey in markerNameAndImageUrlMap) { let imageUrl = markerNameAndImageUrlMap[markerKey]; loader.add(markerKey, imageUrl); } Observable.create() return defer(() => {

How to keep RxJs observable from completing on error?

≯℡__Kan透↙ 提交于 2019-12-13 02:58:02
问题 I have an angular reactive form that makes a simple GET request. If for example, I should get some sort of HTTP error. The observable todo$ has now completed I can no longer change my search options and click to retry searching. I've made a stackblitz demo, in the demo I've added my subscription inside an initializer and if there is an error on the stream I catch it. After I catch it, I call the initializer again. This works but seems like the wrong way to handle errors. I've set up the form

Component cannot subscribe to data source

社会主义新天地 提交于 2019-12-13 02:58:01
问题 I have this component listening for messages from a service. Note that every console.log() statement shown below is hit at least once, everything gets logged. That is, except "adding message to array" - that does not get logged, but it should get logged! Here is the component: import {Component, OnInit, Inject} from '@angular/core'; import {ChromeDataService} from '../../../../shared/services/events'; @Component({ providers: [ChromeDataService], selector: 'app-events-list', templateUrl: '.

Multiple subscriptions without recalculate common part

a 夏天 提交于 2019-12-13 02:53:17
问题 const ex = ajax.getJSON('https://httpbin.org/get?a=24'); ex.pipe(pluck('args')).subscribe(x => console.log('Args: ', x)); ex.pipe(pluck('headers')).subscribe(x => console.log('Headers: ', x)); Code above(StackBlitz) initiates two ajax requests by one for each subscription. What is correct way to initiate only one observable pipe/chain for all existing subscriptions? I can achieve that with introduce a Promise for ajax(StackBlitz): const p = new Promise(resolve => { ajax.getJSON('https:/

Do I need to `complete()` takeUntil Subject inside ngOnDestroy?

懵懂的女人 提交于 2019-12-13 02:52:21
问题 To avoid Observable memory leaks inside Components, I am using takeUntil() operator before subscribing to Observable. I write something like this inside my components: private unsubscribe$ = new Subject(); ngOnInit(): void { this.http .get('test') .pipe(takeUntil(this.unsubscribe$)) .subscribe((x) => console.log(x)); } ngOnDestroy(): void { this.unsubscribe$.next(); this.unsubscribe$.complete(); // <--- ?? } Finally my question is following: Do I need to write this.unsubscribe$.complete(); or

One call main, multiple responses in ASP.NET MVC + angular 6

人走茶凉 提交于 2019-12-13 02:26:32
问题 First of all, I have no idea if this is possible! and I'm struggling to find an answer. I think I don't know what to search for! I have an endpoint that returns IEnumerable , I want to divide the response so I used .Skip().Take() Now when I get the first take, how can I get the second one without invoking the same endpoint! The problem is IEnumerable gets the data from another service where it is not possible to divide, so I have to get everything at once and then I have to call another "SLOW