rxjs

Angular 5 subscribe and unsubscribe Observable

送分小仙女□ 提交于 2020-01-14 19:50:51
问题 I have to get datas from two subscribe but I get always data of the first one. I have a data shared service : import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; @Injectable() export class DataService { private source = new BehaviorSubject<any>(''); data = this.source.asObservable(); constructor() { } update(values: any) { this.source.next(values); } } Before leaving search component, I call update method. Now, I'm on the results component. I

RxJS (5.0rc4): Pause and resume an interval timer

旧时模样 提交于 2020-01-14 12:10:44
问题 I am using Rx to keep an animation clock. Every animation frame, it maps an interval tick to the new values for that tick. Suppose I want to pause the animation. The most natural way would be to somehow suspend the clock rx and then resume it at a later time. Unsubscribe then resubscribe isn't a natural fit, because this animation clock is a cold observable. I don't want to restart the animation when they resume. If I go for a workaround method, I will have to generate a new resume rx, vastly

RxJS (5.0rc4): Pause and resume an interval timer

江枫思渺然 提交于 2020-01-14 12:10:35
问题 I am using Rx to keep an animation clock. Every animation frame, it maps an interval tick to the new values for that tick. Suppose I want to pause the animation. The most natural way would be to somehow suspend the clock rx and then resume it at a later time. Unsubscribe then resubscribe isn't a natural fit, because this animation clock is a cold observable. I don't want to restart the animation when they resume. If I go for a workaround method, I will have to generate a new resume rx, vastly

RxJS (5.0rc4): Pause and resume an interval timer

元气小坏坏 提交于 2020-01-14 12:08:24
问题 I am using Rx to keep an animation clock. Every animation frame, it maps an interval tick to the new values for that tick. Suppose I want to pause the animation. The most natural way would be to somehow suspend the clock rx and then resume it at a later time. Unsubscribe then resubscribe isn't a natural fit, because this animation clock is a cold observable. I don't want to restart the animation when they resume. If I go for a workaround method, I will have to generate a new resume rx, vastly

Angular 6 - rxjs pipe not working on valueChanges

半腔热情 提交于 2020-01-14 10:33:17
问题 I have a reactive form, with a text input. For ease of access in my typescript, I declared: get parentId(): FormControl { return this.addForm.get("parentId") as FormControl; } This part works, the control is properly accessed. Now in my ngOnInit if I do this: this.parentId.valueChanges.subscribe(() => console.log("Changed")); The console log is executed at every character changed in the input, as expected. But if I do this: this.parentId.valueChanges.pipe(tap(() => console.log("Changed")));

Angular6.0发布

谁说胖子不能爱 提交于 2020-01-14 05:30:36
Angular v6 新版本重点关注工具链以及工具链在 Angular 中的运行速度问题。 Angular v6 是统一整体框架、Material 和 CLI 三大 Angular 组件的第一个版本,此次更新更多地关注于工具链上,以使其具有更好的可移植性。 此次更新信息如下: 更新依赖关系: @angular/core 现在依赖于: TypeScript 2.7 RxJS 6.0.0 tslib 1.9.0 @angular/platform-server 现在依赖于 Domino 2.0 特性的小改动: animations: 只能使用 WA-polyfill 和 AnimationBuilder animations: 在转换匹配器中暴露元素和参数 common: 在 NgIf 中使用非模板元素时更好的错误消息 common: 导出函数来格式化数字,百分数,货币和日期 compiler: 实现“enableIvy”编译选项 core: 添加绑定名称到内容更改错误 bug 修复: 即使在 noOp 动画期间也要报告正确的 totalTime 值 避免在路由器返回/刷新期间插入动画 修复增加/减少别名示例 修正 Observable 方法的映射 更新功能信息: 1. ng update ng update <package> 是一个新的 CLI 命令,用于分析 package

Using rx.js, how do I emit a memoized result from an existing observable sequence on a timer?

梦想的初衷 提交于 2020-01-13 19:27:08
问题 I'm currently teaching myself reactive programming with rxjs, and I've set myself a challenge of creating an observable stream which will always emit the same result to a subscriber no matter what. I've memoized the creation of an HTTP "GET" stream given a specific URL, and I'm trying to act on that stream every two seconds, with the outcome being that for each tick of the timer, I'll extract a cached/memoized HTTP result from the original stream. import superagent from 'superagent'; import _

Angular 6 : How to identify forkJoin response

半腔热情 提交于 2020-01-13 12:19:40
问题 Angular 6 : How to identify response of api with forkJoin reqs = []; if (shouldUpdatePhone) { reqs.push(this.customerService.updatePhone(phoneUpdateRequest)) } if (shouldUpdateAddress) { reqs.push(this.customerService.updateAddress(addressUpdateRequest)) } forkJoin(reqs).subscribe(result => { console.log('result :', result); //How to know response is from updatePhone and response from updateAddress? }); How to can i identify response received is belong to updatePhone and updateAddress? based

Angular 6 : How to identify forkJoin response

和自甴很熟 提交于 2020-01-13 12:19:20
问题 Angular 6 : How to identify response of api with forkJoin reqs = []; if (shouldUpdatePhone) { reqs.push(this.customerService.updatePhone(phoneUpdateRequest)) } if (shouldUpdateAddress) { reqs.push(this.customerService.updateAddress(addressUpdateRequest)) } forkJoin(reqs).subscribe(result => { console.log('result :', result); //How to know response is from updatePhone and response from updateAddress? }); How to can i identify response received is belong to updatePhone and updateAddress? based

Angular 6 : How to identify forkJoin response

﹥>﹥吖頭↗ 提交于 2020-01-13 12:19:19
问题 Angular 6 : How to identify response of api with forkJoin reqs = []; if (shouldUpdatePhone) { reqs.push(this.customerService.updatePhone(phoneUpdateRequest)) } if (shouldUpdateAddress) { reqs.push(this.customerService.updateAddress(addressUpdateRequest)) } forkJoin(reqs).subscribe(result => { console.log('result :', result); //How to know response is from updatePhone and response from updateAddress? }); How to can i identify response received is belong to updatePhone and updateAddress? based