Skip to content

Commit

Permalink
use abstract class (#968)
Browse files Browse the repository at this point in the history
* use abstract class

* include source map in dist
  • Loading branch information
rmorshea committed Apr 11, 2023
1 parent b1951cc commit 0aab4b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/client/packages/@reactpy/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"name": "@reactpy/client",
"type": "module",
"version": "0.3.0",
"version": "0.3.1",
"dependencies": {
"event-to-object": "^0.1.2",
"json-pointer": "^0.6.2"
Expand Down
9 changes: 6 additions & 3 deletions src/client/packages/@reactpy/client/src/reactpy-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ export interface ReactPyClient {
*
* @param message The message to send. Messages must have a `type` property.
*/
sendMessage: (message: any) => void;
sendMessage(message: any): void;

/**
* Load a module from the server.
* @param moduleName The name of the module to load.
* @returns A promise that resolves to the module.
*/
loadModule: (moduleName: string) => Promise<ReactPyModule>;
loadModule(moduleName: string): Promise<ReactPyModule>;
}

export class BaseReactPyClient implements Partial<ReactPyClient> {
export abstract class BaseReactPyClient implements ReactPyClient {
private readonly handlers: { [key: string]: ((message: any) => void)[] } = {};
protected readonly ready: Promise<void>;
private resolveReady: (value: undefined) => void;
Expand All @@ -49,6 +49,9 @@ export class BaseReactPyClient implements Partial<ReactPyClient> {
};
}

abstract sendMessage(message: any): void;
abstract loadModule(moduleName: string): Promise<ReactPyModule>;

/**
* Handle an incoming message.
*
Expand Down
5 changes: 4 additions & 1 deletion src/client/tsconfig.package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["DOM", "DOM.Iterable", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
"noUnusedLocals": true,
"resolveJsonModule": true,
"skipLibCheck": false,
"sourceMap": true,
"strict": true,
"target": "esnext"
}
Expand Down

0 comments on commit 0aab4b0

Please sign in to comment.