Implement EventListener instead of func juggling

This commit is contained in:
2025-10-09 11:35:35 +02:00
parent 46e7f7540b
commit 10a19717ad
4 changed files with 18 additions and 17 deletions

View File

@@ -47,9 +47,9 @@ class trserver {
rpc.setRequestHeader('X-Transmission-Session-Id', this.#sessionHeader);
}
rpc.setRequestHeader('content-type', 'application/json');
rpc.addEventListener('readystatechange', this.#handler.bind(this));
rpc.addEventListener('timeout', this.#handler.bind(this));
rpc.addEventListener('error', this.#handler.bind(this));
rpc.addEventListener('readystatechange', this);
rpc.addEventListener('timeout', this);
rpc.addEventListener('error', this);
rpc.timeout = 10000;
try {
rpc.send(JSON.stringify(request.payload));
@@ -65,7 +65,7 @@ class trserver {
this.#rpccall(tag);
}
#handler(e) {
handleEvent(e) {
switch (e.type) {
case 'readystatechange':
if (e.target.readyState == 4) {