member_webapp/src/app/app-rpc.module.ts

37 lines
838 B
TypeScript
Raw Normal View History

2018-04-06 06:59:49 +00:00
import { NgModule } from '@angular/core';
import { RPCModule } from '@loafer/ng-rpc';
import {
RPC_CODEC,
RPC_RWC,
} from '@loafer/ng-rpc/core';
import { JSONRPCClientCodec } from '@loafer/ng-rpc/protocol/json';
import {
RPCClientWebsocketRWC,
RxWebsocketSubjectConfig,
} from '@loafer/ng-rpc/client/rwc/websocket';
import { environment } from '../environments/environment';
@NgModule({
exports: [
RPCModule,
],
imports: [
RPCModule.forRoot({}),
],
providers: [
{provide: 'WEBAPP_RPC_CONFIG', useValue: environment.webappRPCConfig},
{provide: RPC_CODEC, useFactory: () => new JSONRPCClientCodec()},
{
provide: RPC_RWC,
useFactory: (config: RxWebsocketSubjectConfig) => new RPCClientWebsocketRWC(config),
deps: ['WEBAPP_RPC_CONFIG']
},
]
})
export class AppRPCModule { }