Repository: xpodev/seamless (language: python)

Issue:
Custom events on client side
I'm building a small chat application and I'm trying to send messages from the server to
the clients.

There's no official way of creating custom client side events, and currently I'm using the internal
event system which is used to pass DOM events to the server.

I have the following JS code as the `init` code of the `Chat` component:
```js
const chat = this;

seamless.instance.registerEventListener("chat", "message", async (data) => {
    const messageObject = await seamless.instance.getComponent("ChatMessage", {
        message: data.data,
        user: data.from,
    });
    const element = seamless.instance.render(messageObject, chat);
});
```

From the server side, I'm using this code to send messages to all clients:
```py
async def send(message):
        await server.emit("chat:message", message)
```

I'm using `chat:message` since that's how `seamless.instance.registerEventListener` creates new events.

> Note: The `server` variable was retrieved in unconventional ways, which I talked about in #46.


Discussion / hints:

Fix patch:
diff --git a/node/packages/core/src/index.ts b/node/packages/core/src/index.ts
index b83dc91..ee0c422 100644
--- a/node/packages/core/src/index.ts
+++ b/node/packages/core/src/index.ts
@@ -130,21 +130,16 @@ class Seamless {
   }
 
   registerEventListener(
-    seamlessId: string,
     event: string,
     callback: (e: any) => any
   ) {
-    this.socket.on(`${seamlessId}:${event}`, callback);
+    this.socket.on(event, callback);
   }
 
   emit(event: string, ...args: any[]) {
     this.socket.emit(event, ...args);
   }
 
-  sendCustomEvent(event: string, data: any) {
-    this.socket.emit("custom", event, data);
-  }
-
   sendWaitResponse<T>(event: string, ...args: any[]) {
     return new Promise<T>((resolve) => {
       this.socket.emit(event, ...args, resolve);


Test patch:
diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml
index 5de56d6..7ced67a 100644
--- a/.github/workflows/python-test.yml
+++ b/.github/workflows/python-test.yml
@@ -6,6 +6,8 @@ on:
       - main
       - dev/v\d+\.\d+\.\d+
     types: [opened, reopened, synchronize]
+    paths:
+      - 'seamless/**/*.py'
 
 permissions:
   contents: read