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", "@ngrx/store": "^5.2.0",
"core-js": "^2.5.4", "core-js": "^2.5.4",
"rxjs": "^6.0.0", "rxjs": "^6.0.0",
"rxjs-compat": "^6.0.0",
"zone.js": "^0.8.26" "zone.js": "^0.8.26"
}, },
"devDependencies": { "devDependencies": {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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