Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on rxjs-compat #473

Merged
merged 1 commit into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/formly/components/autocomplete/test.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AutocompleteService } from '@gsa-sam/sam-ui-elements';
/* tslint:disable */
import { Observable,of } from 'rxjs';
import { map } from 'rxjs/operators';
/* tslint:enable */

export class TestAutocompleteService implements AutocompleteService {
Expand All @@ -14,6 +15,6 @@ export class TestAutocompleteService implements AutocompleteService {
{ key: 'cc-carlos', value: 'Carlos', category: 'People', subhead: 'CSS Guru' },
{ key: 'cc-colin', value: 'Colin', category: 'People', subhead: 'UI Developer' },
{ key: 'cc-diego', value: 'Diego', category: 'People', subhead: 'UI Developer' }
]).map(o => o);
]).pipe(map(o => o));
}
}
119 changes: 57 additions & 62 deletions src/ui-kit/components/comments/comments.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,9 @@ import {
Validators,
ControlValueAccessor
} from '@angular/forms';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/mergeMap';


import { Observable, Subscription, Subject ,of} from 'rxjs';
import 'rxjs/add/operator/merge';
import 'rxjs/add/operator/catch';


import * as moment from 'moment';

import { SamAccordionComponent } from '../accordion';
import { Observable, Subscription, Subject ,of, fromEvent} from 'rxjs';
import { flatMap, catchError, merge } from 'rxjs/operators';

import { CommentsService } from './comments.service';
import { Comment } from './interfaces';
Expand Down Expand Up @@ -101,74 +92,78 @@ export class SamCommentsComponent implements OnInit {
});

// Register observables for 'click' events
this.showButtonStream =
Observable.fromEvent(this.showCommentsButton.nativeElement, 'click');
this.hideCommentsStream =
Observable.fromEvent(this.hideCommentsButton.nativeElement, 'click');
this.enterEventStream =
Observable.fromEvent(this.textArea.nativeElement, 'keyup');
this.showButtonStream = fromEvent(this.showCommentsButton.nativeElement, 'click');
this.hideCommentsStream = fromEvent(this.hideCommentsButton.nativeElement, 'click');
this.enterEventStream = fromEvent(this.textArea.nativeElement, 'keyup');

// Map DOM events to actions
this.getCommentsStream =
this.showButtonStream
.flatMap(event => {
return this.commentsService.getComments()
.catch(error => of(error));
});
this.showButtonStream.pipe(
flatMap(event => {
return this.commentsService.getComments().pipe(
catchError(error => of(error))
);
})
);

this.collapseCommentsStream =
this.hideCommentsStream
.flatMap(event => {
return this.commentsService.getInitialState()
.catch(error => of(error));
});
this.hideCommentsStream.pipe(
flatMap(event => {
return this.commentsService.getInitialState().pipe(
catchError(error => of(error))
);
}));

this.submitStream =
this.enterEventStream
.flatMap(event => {
if (event.key === 'Enter' || event.keyIdentified === 'Enter') {
this.form.controls.datetime.setValue(Date.now());
return this.commentsService.postComment(this.form.value)
.catch(error => of(error));
} else {
return of(undefined);
}
})
.flatMap(event => {
if (event instanceof Error) {
return of(this.comments);
} else if (event === null || event === undefined) {
return of(this.comments);
} else {
this.form.controls.text.setValue('');
return of(event)
.catch(error => of(error));
}
});
this.enterEventStream.pipe(
flatMap(event => {
if (event.key === 'Enter' || event.keyIdentified === 'Enter') {
this.form.controls.datetime.setValue(Date.now());
return this.commentsService.postComment(this.form.value).pipe(
catchError(error => of(error))
);
} else {
return of(undefined);
}
}),
flatMap(event => {
if (event instanceof Error) {
return of(this.comments);
} else if (event === null || event === undefined) {
return of(this.comments);
} else {
this.form.controls.text.setValue('');
return of(event).pipe(
catchError(error => of(error))
);
}
})
);

const sub =
this.deleteStream
.flatMap((comment) => {
return this.commentsService.deleteComment(comment)
.catch(err => of(err));
})
.flatMap((event) => {
this.deleteStream.pipe(
flatMap((comment) => {
return this.commentsService.deleteComment(comment).pipe(
catchError(err => of(err)));
}),
flatMap((event) => {
if (event instanceof Error) {
return of(this.comments);
} else {
return of(event)
.catch(err => of(err));
return of(event).pipe(
catchError(err => of(err))
);
}
});
}));

// Subscribe to mapped DOM events
this.commentsSubscription =
this.commentsService
.getInitialState() // Initialize stream with initial state
.merge(this.getCommentsStream) // Add comments stream
.merge(this.collapseCommentsStream) // Add collapse stream
.merge(this.submitStream) // Add submit stream
.merge(sub)
.getInitialState().pipe( // Initialize stream with initial state
merge(this.getCommentsStream), // Add comments stream
merge(this.collapseCommentsStream), // Add collapse stream
merge(this.submitStream), // Add submit stream
merge(sub))
.subscribe(
(comments) => {
this.comments = comments;
Expand Down
2 changes: 1 addition & 1 deletion src/ui-kit/components/data-table/sort-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import {SamSortDirective, SamSortable, SortDirection} from './sort.directive';
import {CdkColumnDef} from '@angular/cdk/table';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {Subscription} from 'rxjs/Subscription';
import {Subscription} from 'rxjs';


/**
Expand Down
17 changes: 9 additions & 8 deletions src/ui-kit/components/image/image.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Component,
Input,
Output,
EventEmitter } from '@angular/core';
import { Observable, Subscription,merge } from 'rxjs';
import { Observable, Subscription, fromEvent } from 'rxjs';
import { merge } from 'rxjs/operators';

@Component({
selector: 'sam-image',
Expand Down Expand Up @@ -55,22 +56,22 @@ export class SamImageComponent implements OnInit {

ngOnInit() {
this.fileChangeStream =
Observable.fromEvent(this.filePicker.nativeElement, 'change');
fromEvent(this.filePicker.nativeElement, 'change');
this.editButtonStream =
Observable.fromEvent(this.editButton.nativeElement, 'click');
fromEvent(this.editButton.nativeElement, 'click');
this.cancelButtonStream =
Observable.fromEvent(this.cancelButton.nativeElement, 'click');
fromEvent(this.cancelButton.nativeElement, 'click');
this.saveButtonStream =
Observable.fromEvent(this.saveButton.nativeElement, 'click');
fromEvent(this.saveButton.nativeElement, 'click');

this.reader.onload = (event: any) => {
this.tmpSrc = event.target.result;
};

this.editModeSubscription =
this.editButtonStream
.merge(this.cancelButtonStream)
.merge(this.saveButtonStream)
this.editButtonStream.pipe(
merge(this.cancelButtonStream),
merge(this.saveButtonStream))
.subscribe(
(event) => {
if (this.editable) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui-kit/components/sidenav/services/sidenav.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';

@Injectable()
export class SidenavService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Observable } from 'rxjs';
import { Observable, merge } from 'rxjs';
import { map } from 'rxjs/operators';
import { DataSource } from '@angular/cdk/collections';

// preparing data source for the hierarchical grid
Expand All @@ -13,10 +14,10 @@ export class HierarchicalDataSource extends DataSource<any> {
const displayDataChanges = [
this.dataChange
];
return Observable.merge(...displayDataChanges).map(() => {
return merge(...displayDataChanges).pipe(map(() => {
this.renderedData = this.dataChange.value;
return this.renderedData;
});
}));
}
disconnect() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Component, OnInit, ViewChild, Input, AfterViewChecked,
Output, EventEmitter, ChangeDetectorRef
} from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { BehaviorSubject } from 'rxjs';
import { SamSortDirective } from '../../../components'
import { HierarchicalDataSource } from './data-source';
import { SamHierarchicalTreeGridConfiguration } from '../models/SamHierarchicalTreeGridConfiguration';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, Input } from "@angular/core";
import { Observable, BehaviorSubject } from "rxjs";
import { Observable, BehaviorSubject, of } from "rxjs";
import { SamHiercarchicalServiceInterface, SamHiercarchicalServiceResult } from "../hierarchical-interface";
import { SamHierarchicalTreeConfiguration } from "../models/SamHierarchicalTreeConfiguration";
import { Sort } from "../../../components/data-table/sort.directive";
Expand Down Expand Up @@ -233,7 +233,7 @@ export class SamHierarchicalTreeComponent implements OnInit {
if (result) {
this.resultItems = this.resultItems.concat(result.items)
}
this.gridResults = Observable.of(this.resultItems);
this.gridResults = of(this.resultItems);
}
);
}
Expand All @@ -251,7 +251,7 @@ export class SamHierarchicalTreeComponent implements OnInit {
this.totalItems = result.totalItems;
}
this.results = [];
this.gridResults = Observable.of(this.resultItems);
this.gridResults = of(this.resultItems);
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Injectable } from '@angular/core';

import { ServiceModel, ServiceProperty } from './service-property';
import { DataStore } from '../store';
import { Observable } from 'rxjs';
import { Subject } from 'rxjs/Subject';
import { Observable , Subject } from 'rxjs';

export type DataLayoutProperty = 'data'
| 'filters' | 'pagination' | 'sort' | 'filterFields';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import 'rxjs/add/operator/distinctUntilChanged';
import { Observable , BehaviorSubject } from 'rxjs';
import { map, distinctUntilChanged } from 'rxjs/operators';

export interface ServicePropertyObj {
[key: string]: ServiceProperty
Expand Down Expand Up @@ -92,8 +91,10 @@ export class ServiceModel extends AbstractServiceProperty {
key => {
this.properties[key] = new ServiceProperty(
{ name: key, value: properties[key] },
stream.map(value => value[key])
.distinctUntilChanged()
stream.pipe(
map(value => value[key]),
distinctUntilChanged()
)
);
}
);
Expand Down Expand Up @@ -121,4 +122,4 @@ export class ServiceModel extends AbstractServiceProperty {
this._updateFn = fn;
this._registerProperties();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable , BehaviorSubject } from 'rxjs';

export interface DataStoreEvent {
type: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {Scrollable} from './scroll/scrollable';
import {ScrollStrategy} from './scroll/scroll-strategy';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {ESCAPE} from '@angular/cdk/keycodes';
import {Subscription} from 'rxjs/Subscription';
import {Subscription} from 'rxjs';


/** Default set of positions for the overlay. Follows the behavior of a dropdown. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {PortalHost, Portal} from '@angular/cdk/portal';

import {OverlayState} from './overlay-state';
import {ScrollStrategy} from './scroll/scroll-strategy';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {Observable, Subject} from 'rxjs';

/**
* Reference to an overlay that has been created with the Overlay service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
OverlayConnectionPosition,
ConnectedOverlayPositionChange, ScrollableViewProperties
} from './connected-position';
import {Subject} from 'rxjs/Subject';
import {Observable} from 'rxjs/Observable';
import {Subject, Observable} from 'rxjs';
import {Scrollable} from '../scroll/scrollable';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import {ScrollStrategy, getMdScrollStrategyAlreadyAttachedError} from './scroll-strategy';
import {OverlayRef} from '../overlay-ref';
import {Subscription} from 'rxjs/Subscription';
import {Subscription} from 'rxjs';
import {ScrollDispatcher} from './scroll-dispatcher';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Subscription} from 'rxjs/Subscription';
import {Subscription} from 'rxjs';
import {ScrollStrategy, getMdScrollStrategyAlreadyAttachedError} from './scroll-strategy';
import {OverlayRef} from '../overlay-ref';
import {ScrollDispatcher} from './scroll-dispatcher';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {ElementRef, Injectable, NgZone, Optional, SkipSelf} from '@angular/core'
// import {Platform} from '@angular/cdk';
import {Platform} from '@angular/cdk/platform';
import {Scrollable} from './scrollable';
import {Subject} from 'rxjs/Subject';
import {Subscription} from 'rxjs/Subscription';
import {fromEvent} from 'rxjs/observable/fromEvent';
import {merge} from 'rxjs/observable/merge';
import {Subject, Subscription, fromEvent, merge} from 'rxjs';
// import {auditTime} from '@angular/cdk';
import {auditTime} from 'rxjs/operators';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
*/

import {Directive, ElementRef, OnInit, OnDestroy, NgZone, Renderer2} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {Observable, Subject} from 'rxjs';
import {ScrollDispatcher} from './scroll-dispatcher';


Expand Down
Loading