Skip to content

Commit

Permalink
chore(requestable): rr
Browse files Browse the repository at this point in the history
  • Loading branch information
radiorz committed Aug 1, 2024
1 parent a1ac0fc commit ae871b6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/requestable/lib/RR.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @author
* @file RR.ts
* @fileBase RR
* @path packages\requestable\lib\RR.ts
* @from
* @desc 有时候想要进行双向的请求响应通信
* @todo
*
*
* @done
* @example
*/

import { Emitter, Message } from './common';
import { Requestable, RequestableOptions, RequestOptions } from './Requestable';
import { Handler, Responsive, ResponsiveOptions } from './Responsive';

export interface RROptions {
emitter: Emitter | null;
requestableOptions?: Partial<RequestableOptions>;
responsiveOptions?: Partial<ResponsiveOptions>;
}
export class RR {
requestable: Requestable;
responsive: Responsive;
constructor(options?: Partial<RROptions>) {
this.requestable = new Requestable({ emitter: options?.emitter, ...options?.requestableOptions });
this.responsive = new Responsive({ emitter: options?.emitter, ...options?.responsiveOptions });
}
init() {
this.responsive.init();
this.requestable.init();
}
async request(options: RequestOptions): Promise<Message | unknown> {
return this.requestable.request(options);
}
addRoute(url: string, handler: Handler) {
return this.responsive.addRoute(url, handler);
}
}
1 change: 1 addition & 0 deletions packages/requestable/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './Requestable';
export * from './Responsive';
export * from './common';
export * from './RR';

0 comments on commit ae871b6

Please sign in to comment.