RpcProviderInterface.d.ts 906 B

1234567891011121314151617181920
  1. import { EventInterface } from 'microevent.ts';
  2. interface RpcProviderInterface {
  3. dispatch(message: any): void;
  4. rpc<T, U>(id: string, payload?: T, transfer?: Array<any>): Promise<U>;
  5. signal<T>(id: string, payload?: T, transfer?: Array<any>): this;
  6. registerRpcHandler<T, U>(id: string, handler: RpcProviderInterface.RpcHandler<T, U>): this;
  7. registerSignalHandler<T>(id: string, handler: RpcProviderInterface.SignalHandler<T>): this;
  8. deregisterRpcHandler<T, U>(id: string, handler: RpcProviderInterface.RpcHandler<T, U>): this;
  9. deregisterSignalHandler<T>(id: string, handler: RpcProviderInterface.SignalHandler<T>): this;
  10. error: EventInterface<Error>;
  11. }
  12. declare module RpcProviderInterface {
  13. interface RpcHandler<T, U> {
  14. (payload?: T): Promise<U> | U;
  15. }
  16. interface SignalHandler<T> {
  17. (payload?: T): void;
  18. }
  19. }
  20. export default RpcProviderInterface;