Upgarde to Angular 6 + RxJS 6 (no rxjs-compat)

This commit is contained in:
BoykoAlex
2018-07-03 16:39:36 -04:00
parent 45503cc2d2
commit c130c5cc59
8 changed files with 43 additions and 42 deletions

View File

@@ -4,6 +4,7 @@
*/
(function (global) {
System.config({
transpiler: 'plugin-babel',
paths: {
// paths serve as alias
'npm:': 'node_modules/'
@@ -24,8 +25,6 @@
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
// 'rxjs/operators': 'npm:rxjs@5.4.3/operators/index.js',
'rx': 'npm:rx',
'rxjs': 'npm:rxjs',
'jointjs': 'npm:jointjs',
'jquery': 'npm:jquery',
@@ -35,9 +34,12 @@
'dagre': 'npm:dagre',
'codemirror': 'npm:codemirror',
'moment': 'npm:moment/moment.js',
'ngx-bootstrap': 'npm:ngx-bootstrap/bundles/ngx-bootstrap.umd.js',
'ngx-bootstrap': 'npm:ngx-bootstrap/bundles/ngx-bootstrap.es2015.js',
'ts-disposables': 'npm:ts-disposables',
'jshint': 'npm:jshint/dist/jshint.js'
'jshint': 'npm:jshint/dist/jshint.js',
'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js',
'systemjs-babel-build': 'npm:systemjs-plugin-babel/systemjs-babel-browser.js'
},
meta: {
'lodash': {
@@ -63,6 +65,7 @@
main: './dist/rx.js'
},
rxjs: {
main: 'index.js',
defaultExtension: 'js'
},
'rxjs/operators': {

View File

@@ -1,8 +1,8 @@
import {Directive, Input, Output, EventEmitter, Inject, ElementRef, OnInit, OnDestroy,} from '@angular/core';
import {DOCUMENT} from '@angular/platform-browser'
import {Observable} from 'rxjs/Observable';
import { sampleTime } from 'rxjs/operators/sampleTime';
import 'rxjs/add/observable/fromEvent';
import { fromEvent } from "rxjs";
import { sampleTime } from 'rxjs/operators';
import { CompositeDisposable, Disposable } from 'ts-disposables';
import * as _$ from 'jquery';
const $ : any = _$;
@@ -123,11 +123,11 @@ export class ResizerDirective implements OnInit, OnDestroy {
// Need to set left and right elements width and fire events on init when DOM is built
this.splitSize = this._splitSize;
let subscription1 = Observable.fromEvent($(this.document).get(0), 'mousemove')
let subscription1 = fromEvent($(this.document).get(0), 'mousemove')
.pipe(sampleTime(300))
.subscribe(this.mouseMoveHandler);
this._subscriptions.add(Disposable.create(() => subscription1.unsubscribe()));
let subscription2 = Observable.fromEvent($(this.document).get(0), 'mouseup')
let subscription2 = fromEvent($(this.document).get(0), 'mouseup')
.subscribe(e => {
if (this.dragInProgress) {
this.mousemove(e);

View File

@@ -41,14 +41,15 @@ export class Utils {
// If one of the ends is not a model, the link has no siblings.
if (!srcId || !trgId) { return; }
let siblings = _.filter(graph.getLinks(), (sibling : dia.Link) => {
const siblings: dia.Link[] = graph.getLinks().filter((sibling: dia.Link) => {
let _srcId = sibling.get('source').id;
let _trgId = sibling.get('target').id;
let vertices = sibling.get('vertices');
let fanRouted = !vertices || vertices.length === 0 || sibling.get('fanRouted');
const _srcId = sibling.get('source').id;
const _trgId = sibling.get('target').id;
const vertices = sibling.get('vertices');
const fanRouted = !vertices || vertices.length === 0 || sibling.get('fanRouted');
return ((_srcId === srcId && _trgId === trgId) || (_srcId === trgId && _trgId === srcId)) && fanRouted;
});
switch (siblings.length) {
@@ -88,7 +89,7 @@ export class Utils {
// This is the maximum distance between links
let gap = 20;
_.each(siblings, (sibling : dia.Link, index : number) => {
siblings.forEach((sibling: dia.Link, index: number) => {
// We want the offset values to be calculated as follows 0, 20, 20, 40, 40, 60, 60 ..
let offset = gap * Math.ceil(index / 2);

View File

@@ -1,5 +1,5 @@
import { Component, Input, Output, ElementRef, EventEmitter, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
import { debounceTime } from 'rxjs/operators/debounceTime';
import { debounceTime } from 'rxjs/operators';
import { dia } from 'jointjs';
import { Flo } from '../shared/flo-common';
import { Shapes, Constants } from '../shared/shapes';
@@ -7,9 +7,7 @@ import { Utils } from './editor-utils';
import { CompositeDisposable, Disposable } from 'ts-disposables';
import * as _$ from 'jquery';
import * as _ from 'lodash';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable, Subject, BehaviorSubject } from 'rxjs';
const joint : any = Flo.joint;
const $ : any = _$;

View File

@@ -1,6 +1,6 @@
import {Component, ElementRef, Input, Output, EventEmitter, OnInit, OnDestroy, OnChanges, SimpleChanges, Inject, ViewEncapsulation} from '@angular/core';
import { Subject } from 'rxjs/Subject';
import { debounceTime } from 'rxjs/operators/debounceTime';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { dia } from 'jointjs';
import { Flo } from '../shared/flo-common';
import { Shapes, Constants } from './../shared/shapes';

View File

@@ -1,5 +1,5 @@
import { dia, g } from 'jointjs';
import { Observable } from 'rxjs/Observable';
import { Observable } from "rxjs";
import * as _joint from 'jointjs';
import * as _$ from 'jquery';

View File

@@ -1,10 +1,8 @@
import { dia } from 'jointjs';
import { ValidatorFn, AsyncValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms'
import { Flo } from './flo-common';
import { Subject } from 'rxjs/Subject'
import { Observable } from 'rxjs/Observable';
import { debounceTime } from 'rxjs/operators/debounceTime';
import { mergeMap } from 'rxjs/operators/mergeMap';
import { Subject, Observable } from 'rxjs'
import { debounceTime, mergeMap } from 'rxjs/operators';
export namespace Properties {