observable

angular 2 Property 'push' does not exist on type 'Observable'

笑着哭i 提交于 2019-12-11 08:54:28
问题 I am having a problem with push data component.ts import { Component, OnInit } from '@angular/core'; import { AngularFireDatabase } from 'angularfire2/database'; import { Observable } from 'rxjs'; @Component({ selector: 'app-content', templateUrl: './content.component.html', styleUrls: ['./content.component.css'] }) export class ContentComponent implements OnInit { courses$:Observable<any[]>; authors$:Observable<any[]>; constructor(db:AngularFireDatabase){ this.courses$ = db.list('/courses')

Observable concat method on array returns the same array

為{幸葍}努か 提交于 2019-12-11 08:49:26
问题 In my service I try to solve the next problem. I have a json file with the names of other json files (cards): { "filename1" : ... , "filename2" : ... , ... "filenameN" : ... } I need to load all that files. "filenameX" files have some card data : { dataX } I need to combine loaded data in object: { "filename1" : { data1 }, "filename2" : { data2 }, ... "filenameN" : { dataN } } I create Observer for any file loading and try to combine them to a high-level single Observer which is resolved when

SwiftUI - Using 'ObservableObject' and @EnvironmentObject to Conditionally Display View

倖福魔咒の 提交于 2019-12-11 07:47:25
问题 I would like to conditionally display different views in my application - if a certain boolean is true, one view will be displayed. If it is false, a different view will be displayed. This boolean is within an ObservableObject class, and is changed from one of the views that will be displayed. PracticeStatus.swift (the parent view) import Foundation import SwiftUI import Combine class PracticeStatus: ObservableObject { @Published var showResults:Bool = false } PracticeView.swift (the parent

How to calculate the sum for the year angular 4

大兔子大兔子 提交于 2019-12-11 07:30:16
问题 I have created to sum the costs between each other but now I need to sum all the budget for complete year. I have tried this but this is not working it is showing me undefined. Costs is an interface that has a variable created of type date and the variable costs of type number and the id of the actual costs of planned costs it is sending to an array lists actualcostIds. So how it is possible to calculate all the sum from 1 January to 31 December Below you will find my code for sum for every

Return Observable from inside nested callbacks functions

南笙酒味 提交于 2019-12-11 07:26:32
问题 Good afternoon! I'm currently developing a web app in Angular2/4 and I have a problem with Observables. The goal is, inside a component, to call a function and when that function finishes, I want some code to be executed. So, the code in the "myComp.component.ts" file is: this.myService.myFunc1().subscribe(() => { // this code has to be executed after myFunc1() finishes. }); The problem is inside the "myFunc1()" function of the "myService.service.ts" file. The structure of this function is

Angular 2 array after subscribe has elements but length is 0

此生再无相见时 提交于 2019-12-11 07:23:18
问题 I'm using Angular 2 and I have noticed an unexpected behaviour. I have a datasource class, which extends DataSource, with two variables: private archives = new BehaviorSubject<MyArchive[]>([]); public archives$: Observable<MyArchive[]> = this.archives.asObservable(); private filteredArchive: MyArchive[]; I update archives this way within the class: this.archives.next(this.filteredArchive); Outside in another class I try to subscribe to the observable but it doesn't work: ngAfterViewInit():

How to split a data frame from an arrayBuffer with RxJS?

☆樱花仙子☆ 提交于 2019-12-11 06:58:12
问题 I'm using websocket to receive data frame from hardware. The data frame is defined like this: 0xbb(head) ---data--- 0xee(tail) the received data is store in Uint8Array, there maybe multiple frame: var buffer = new Uint8Array([0xbb,0,0,0,0xee,0xbb,1,1,1,0xee,0xbb,3,3,3,0xee]); and I can convert the array to observable: var obs= Rx.Observable.from(buffer); RxMarbles: --0xbb--0--0--0--0xee--0xbb--1--1--1--0xee--0xbb--2--2--2--0xee------ ------------------000------------------111-----------------

break up buffer into size rxjs

大城市里の小女人 提交于 2019-12-11 06:37:28
问题 I have an observable get data from stream each time at size 512 each next I have to break it up to 200 char at other observable and keep [12] char in other buffer to concatenate with next block, I solve it by using new subject and for loop, I believe there maybe a better, more pretty solution. received Observable ---------------------------------------- 1st next [512] -------> [112] [200] [200] -------> [200] [200] 2nd next [512][ 112 ] --> [24][200][200] [88+ 112 ] --> [200] [200] 3rd next

Observable is not saving the data when refreshing the page manually

浪子不回头ぞ 提交于 2019-12-11 06:01:27
问题 I have this code in my service constructor: this.getUser().subscribe( data => this.user = data.text(), error => console.log(error) ); When navigating in my app with router links (from menu) this code works, but when refreshing the page manually... data.text() includes the logged-in user (I can see it if I print it to console) but this.user variable is not saving it and it remains "undefined"! I tried so far using a setTimeout or a BehaviorSubject but with no luck: private _subject = new

Angular 2 - forkJoin can't bind the correct lass

久未见 提交于 2019-12-11 05:55:51
问题 I'm trying to do multiple ajax calls together. I can't figure out what is wrong with these lines. Seems like the second input of the subscribe function is processed as Group[] instead of Authorization[] Observable.forkJoin( [this.userService.getAllGroups(),this.userService.getAllAuthorizations()] ) .subscribe( ([groups,authorizations]) => { this.groups = groups; this.authorizations = authorizations; //error: Type 'Group[]' is not assignable to type 'Authorization[]' this.loaderService