rxjs

Observable.zip is not a function

吃可爱长大的小学妹 提交于 2019-12-23 07:22:41
问题 VM95422:27 ORIGINAL EXCEPTION: WEBPACK_IMPORTED_MODULE_3_rxjs_Observable .Observable.zip is not a function Tried various imports // import 'rxjs/add/operator/zip'; // import 'rxjs/add/observable/zip-static'; // import 'rxjs/add/operator/zip'; import 'rxjs/operator/zip'; Trying to use it like that: const zippedUsers: Observable<User[]> = Observable.zip<User>(this.usersObservable); Angular 4, TypeScript 2.1.6 package.json: "rxjs": "^5.1.0", 回答1: maybe something like import {Observable} from

Rendering incremental updates with *ngFor?

谁说胖子不能爱 提交于 2019-12-23 06:28:32
问题 If we have an Observable<Todo[]> , as shown below, is it possible to provide the template with delta updates? For example if the Observable<Todo[]> is getting values from a BehaviorSubject 's next() call, could that broadcast incremental changes. My current understanding is that it has to broadcast the entire new array, but figured I'd check see if anything in this space is available? template: '<todo *ngFor="let todo of todos$ | async" [todo]="todo"><todo>' Background I'm attempting to

RxJs BehaviorSubject's next() method in service

心已入冬 提交于 2019-12-23 06:07:56
问题 I use the following approach in order to refresh Details page after a new record added. I also need to refresh after updating a record as well. EventProxyService export class EventProxyService { private eventTracker = new BehaviorSubject<any>(); getEvent(): Observable<any> { return this.eventTracker.asObservable(); } setEvent(param: any): void { this.eventTracker.next(param); } } CreateComponent: export class CreateComponent implements OnInit { constructor(private eventProxyService:

How can I get multiple services call to finish before emitting an event

柔情痞子 提交于 2019-12-23 06:07:06
问题 Hello I'm working with angular 5. What I want to achieve is to wait until multiple services calls finish, I don't know if I can use forkJoin operator because the the service calls depends on a parameter, for example: If this parameter is 2, there will be two calls to this service. Is there a way to get this working somehow? Code: for (let i = 0; i < this._periodQtty; i++) { this.service.getPastMonthData(i).subscribe(pastMonthData => { if (pastMonthData && pastMonthData.length > 0) {

How to cancel a composed RxJS observable

浪子不回头ぞ 提交于 2019-12-23 05:45:35
问题 Folks, I have an app using RxJS to handle mouse events. I am composing these events into more complex observable 'gestures'. One such gesture is "shake". The series of events I am trying to compose are: mousedown mousemove left mousemove right mousemove left mousemove right mouseup What I am finding is that mousedown mouseup mousemove left mousemove right mousemove left mousemove right is also triggering the same result. I have made a fiddle demonstrating the issue on codepen. My question in

angular2- Observable getting data from list out of order

孤街浪徒 提交于 2019-12-23 05:32:34
问题 for (let i = 0; i < this.data.VirtualHosts.length; i++) { // get the vh this.apiService.findVH(this.data.VirtualHosts[i]) // then add each vhost to data by concat and then convert to json .subscribe((data) => { this.data = data.docs[0] this.jsonData = this.jsonData.concat(this.data) //console.log("AFTER: " + this.jsonData[i]._id) //console.log("Response for getVH: " + JSON.stringify(this.jsonData)) }) } Here, I loop through a list of ID's of VirtualHosts and do a get call (findVH) on every

ngFor not displaying arrays

泪湿孤枕 提交于 2019-12-23 05:13:23
问题 I have a search service : getErros(start, end): FirebaseListObservable<any>{ this.hey = Rx.Observable.combineLatest( this.db.list('/erros/geral',{ query: { orderByChild: 'titulo', limitToFirst:10, startAt: start, endAt: end } }), this.db.list('/erros/utilsst',{ query: { orderByChild: 'titulo', limitToFirst:10, startAt: start, endAt: end } }), this.db.list('/erros/utilfac',{ query: { orderByChild: 'titulo', limitToFirst:10, startAt: start, endAt: end } }), this.db.list('/erros/utilatas',{

Accumulating and resetting values in a stream

拥有回忆 提交于 2019-12-23 05:07:51
问题 I'm playing with Reactive Programming, using RxJS, and stumbled upon something I'm not sure how to solve. Let's say we implement a vending machine. You insert a coin, select an item, and the machine dispenses an item and returns change. We'll assume that price is always 1 cent, so inserting a quarter (25 cents) should return 24 cents back, and so on. The "tricky" part is that I'd like to be able to handle cases like user inserting 2 coins and then selecting an item. Or selecting an item

Angular 2 Route Guard CanActivate based on Firebase User Role

喜欢而已 提交于 2019-12-23 04:52:24
问题 I've been spending hours and hours working in circles trying to figure this out. I need to secure the routes based on the users roles. constructor(private af: AngularFire, private db: AngularFireDatabase, private router: Router, private auth: AngularFireAuth) { af.auth.subscribe(user => { if (user) { this.getUserRole(user); } else { console.log('no user'); } }); } This at least gets the role: getUserRole(user): any { this.db.list('users', { query: { orderByKey: true, equalTo: user.uid } })

How to chain async actions and wait for the result without store.dispatch

廉价感情. 提交于 2019-12-23 04:47:49
问题 I'm trying to write my INITIALIZE action which should chain some async actions together in the following way Call the initialize action. Call two async actions simultaneously. Wait for the completion of above actions. Run additional one action. Finish initialization. here is the redux flow that I expect INITIALIZATION_STARTED => ASYNC_ACTION_A_STARTED AND ASYNC_ACTION_B_STARTED => ASYNC_ACTION_A_FINISHED AND ASYNC_ACTION_B_FINISHED => ASYNC_ACTION_C_STARTED => ASYNC_ACTION_C_FINISHED =>