This commit is contained in:
crusader 2018-06-20 14:28:47 +09:00
parent 92e71451eb
commit abba37caae
10 changed files with 403 additions and 287 deletions

627
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,6 @@
"@ngrx/store": "^5.2.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
@ -53,4 +52,4 @@
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@loafer/ng-rpc",
"version": "0.0.4",
"version": "0.0.5",
"repository": {
"type": "git",
"url": "https://git.loafle.net/loafer/ng.git"

View File

@ -1,5 +1,4 @@
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { Observable, Subject } from 'rxjs';
import { RPCClientError } from '../protocol/RPCError';
import { RPCClientRWC } from './RPCClientRWC';

View File

@ -1,6 +1,4 @@
import { InjectionToken } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
export interface RPCClientRWC<T> {
connect(queryString?: string): void;

View File

@ -1,6 +1,4 @@
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { map } from 'rxjs/operator/map';
import { Observable, Subject } from 'rxjs';
import {
RxWebsocketSubject,

View File

@ -1,15 +1,6 @@
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import { Subject } from 'rxjs/Subject';
import {
WebSocketSubject,
WebSocketSubjectConfig
} from 'rxjs/observable/dom/WebSocketSubject';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/share';
import 'rxjs/add/operator/takeWhile';
import 'rxjs/add/observable/interval';
import { Observable, Observer, Subject, interval } from 'rxjs';
import { share, distinctUntilChanged, takeWhile } from 'rxjs/operators';
import { WebSocketSubject, WebSocketSubjectConfig } from 'rxjs/webSocket';
export interface RxWebsocketSubjectConfig {
url: string;
@ -31,7 +22,10 @@ export class RxWebsocketSubject<T> extends Subject<T> {
this._connectionStatus = new Observable<boolean>((observer) => {
this._connectionObserver = observer;
}).share().distinctUntilChanged();
}).pipe(
share(),
distinctUntilChanged(),
);
this._wsSubjectConfig = {
url: _config.url,
@ -93,10 +87,11 @@ export class RxWebsocketSubject<T> extends Subject<T> {
}
private reconnect(): void {
this._reconnectionObservable = Observable.interval(this._config.reconnectInterval)
.takeWhile((v, index) => {
this._reconnectionObservable = interval(this._config.reconnectInterval).pipe(
takeWhile((v, index) => {
return index < this._config.reconnectRetry && !this._socket;
});
}));
this._reconnectionObservable.subscribe(
() => {
this.connect();

View File

@ -3,25 +3,13 @@ import {
ModuleWithProviders,
Type,
Inject,
InjectionToken,
} from '@angular/core';
import {
RPC_CODEC,
RPC_RWC,
_ROOT_SUBSCRIBERS,
_FEATURE_SUBSCRIBERS,
} from './core/token';
import {
RPCClientRWC,
} from './client/RPCClientRWC';
import {
RPCClientCodec,
} from './protocol/RPCClientCodec';
import {
RPCService,
} from './service/rpc.service';

View File

@ -1,8 +1,4 @@
import { Injectable, Inject } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import {
RPC_CODEC,

View File

@ -1,5 +1,4 @@
import { Injectable, Inject } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Injectable } from '@angular/core';
import {
Type,
@ -11,7 +10,6 @@ import { TypeUtil } from '@loafer/core/util/TypeUtil';
import {
Class,
Method,
Metadata,
} from '@loafer/core/reflect';
import { RPCSubscriberAnnotation } from '../decorator/rpc-subscriber.decorator';