Skip to content

Commit

Permalink
Fix issue where some Typescript based project transpiler might mangle…
Browse files Browse the repository at this point in the history
… the name (#35)

Co-authored-by: Gérald Divoux <gerald.divoux@ninsight.io>
  • Loading branch information
hsreina and Gérald Divoux authored Mar 12, 2024
1 parent ef1c725 commit 5698991
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { SpacetimeDBClient } from "./spacetimedb";

export type ReducerClass = { new (...args: any[]): Reducer };
export type ReducerClass = {
new (...args: any[]): Reducer;
reducerName: string;
};
export class Reducer {
public static reducerName: string;
public call(..._args: any[]): void {
throw "not implemented";
}
Expand Down
9 changes: 5 additions & 4 deletions src/spacetimedb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ export class SpacetimeDBClient {
* @param table Component to be registered
*/
public static registerTable(table: DatabaseTableClass) {
this.tableClasses.set(table.name, table);
this.tableClasses.set(table.tableName, table);
}

/**
Expand All @@ -722,7 +722,7 @@ export class SpacetimeDBClient {
*/
public static registerTables(...tables: DatabaseTableClass[]) {
for (const table of tables) {
this.tableClasses.set(table.name, table);
this.registerTable(table);
}
}

Expand All @@ -732,7 +732,7 @@ export class SpacetimeDBClient {
* @param reducer Reducer to be registered
*/
public static registerReducer(reducer: ReducerClass) {
this.reducerClasses.set(reducer.name, reducer);
this.reducerClasses.set(reducer.reducerName + "Reducer", reducer);
}

/**
Expand All @@ -741,9 +741,10 @@ export class SpacetimeDBClient {
*/
public static registerReducers(...reducers: ReducerClass[]) {
for (const reducer of reducers) {
this.reducerClasses.set(reducer.name, reducer);
this.registerReducer(reducer);
}
}

/**
* Subscribe to a set of queries, to be notified when rows which match those queries are altered.
*
Expand Down

0 comments on commit 5698991

Please sign in to comment.