observable

Reset and Dispose observable subscriber, Reactive Extensions

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 15:50:02
问题 Suppose I have this : public class UploadDicomSet { public UploadDicomSet() { var cachCleanTimer = Observable.Interval(TimeSpan.FromMinutes(2)); cachCleanTimer.Subscribe(CheckUploadSetList); //Start subscriber } void CheckUploadSetList(long interval) { //Stop and dispose subscriber } public void AddDicomFile(SharedLib.DicomFile dicomFile) { //Renew subscriber, call CheckUploadSetList 2 minutes later } } 1- in CheckUploadSetList I want to dispose or finish observable 2- in AddDicomFile I want

Unit Testing fromEvent observable with withLatestFrom

こ雲淡風輕ζ 提交于 2021-02-10 13:45:32
问题 I have the following observables: public ngAfterViewInit(): void { fromEvent(this.showFeaturesButton.nativeElement, 'click').pipe( takeUntil(this.ngUnsubscribe), withLatestFrom(this.store.pipe(select(fromClientStorage.getSubscription))) ).subscribe(([_event, subscription]) => { this.featureModal.open(FeatureListComponent, { data: { features: subscription.features }, }); }); } I am trying to test using: it('should call modal when feature button is clicked', () => { const subscription:

Angular: refresh token only once

最后都变了- 提交于 2021-02-10 06:41:39
问题 I'm using JWT with refresh token strategy as authentication and I have an interceptor in my Angular client that sends the token as a header. I check for expiration before sending, and refresh the token with my refreshToken if needed. The problem is when sending 2 (or more) requests, both trying to refresh the token. I need a function that sends req for refresh token and when called multiple times at once, makes only 1 http req to the server for refresh and returns the new updated token to all

Optional Observables in combineLatest

余生长醉 提交于 2021-02-08 19:43:35
问题 As definied combineLatest in rx emites only if all values have changed at least once. (so long as each of the source Observables has emitted at least one item) I use it to manipulate views within my android views. For example, I enable a call to action button as soon as all observables emitted a valid value. Otherwise I disable it. Observable.combineLatest( toObservable(email), toObservable(username), toObservable(status), toObservable(phonenumber), toObservable(birthdate), Function5<String,

Optional Observables in combineLatest

偶尔善良 提交于 2021-02-08 19:43:14
问题 As definied combineLatest in rx emites only if all values have changed at least once. (so long as each of the source Observables has emitted at least one item) I use it to manipulate views within my android views. For example, I enable a call to action button as soon as all observables emitted a valid value. Otherwise I disable it. Observable.combineLatest( toObservable(email), toObservable(username), toObservable(status), toObservable(phonenumber), toObservable(birthdate), Function5<String,

Cannot get and set value to BehaviorSubject in angular

杀马特。学长 韩版系。学妹 提交于 2021-02-08 11:51:26
问题 I'm trying to add a boolean value to a BehaviorSubject. However, when I try to console log it says that it is undefined. What I'm doing wrong? This is how I declare it. isDesktopWidth: BehaviorSubject<boolean>; And this is how I use it changeSideBarWidth() { if (this.innerWidth > 767) { this.isDesktopWidth.next(true); } else { this.isDesktopWidth.next(false); } } And then in the ngOnInit this.changeSideBarWidth(); console.log(this.isDesktopWidth.value); But it doesn't display anything in the

Angular 2 http - filter the observable before returning it

放肆的年华 提交于 2021-02-08 11:49:26
问题 In service I have this defined: getAllHTTP(): Observable<IUser[]> { return this.http.get(`${this.url}/users`) .map(res => res.json()) .catch(err => Observable.throw(err)); } and in the component: ngOnInit() { const self = this; this._uService.getAllHTTP().subscribe( function (data) { console.log(data); self.listOfUsers = data }, (error) => console.error(error) ); } So now I wanted to filter the data before passing the observable to component and I did this: getAllHTTP(): Observable<IUser[]> {

Angular 5, Observable and async function

流过昼夜 提交于 2021-02-08 10:38:29
问题 I have been trying to create a function that is similar to http.get(...) but not doing any http. Basically what I have done is that I defined a function async myFunc(): Observable<string> { var myObservable: Observable<string>; //..... // the rest of the function's code comes here // ... return myObservable; } But I always get an error that it is not compatible with ES5/ES3 and should return a Promise object? But I am wondering how it became possible with Angular 5's http.get function? Where

Angular 5, Observable and async function

不想你离开。 提交于 2021-02-08 10:37:48
问题 I have been trying to create a function that is similar to http.get(...) but not doing any http. Basically what I have done is that I defined a function async myFunc(): Observable<string> { var myObservable: Observable<string>; //..... // the rest of the function's code comes here // ... return myObservable; } But I always get an error that it is not compatible with ES5/ES3 and should return a Promise object? But I am wondering how it became possible with Angular 5's http.get function? Where

Make an IObservable subscription concurrent

99封情书 提交于 2021-02-08 08:28:24
问题 I have the following code string dataDirectory = _settingsProvider.DataSettings.BaseDirectory; _solverManagementService.MergedPointCloudProducer(dataDirectory, cancellationToken) .Subscribe(PointCloudMergerCompleted); where the SolverManagementService _solverManagementService is Public class SolverManagementService : ISolverManagementService { public IObservable<IPointCloud> MergedPointCloudProducer(string dataDirectory, CancellationToken token) { return Observable.Create<IPointCloud>(