|
@@ -4,16 +4,24 @@ import {
|
|
WeakDioxusChannel,
|
|
WeakDioxusChannel,
|
|
} from "../../../document/src/ts/eval";
|
|
} from "../../../document/src/ts/eval";
|
|
|
|
|
|
|
|
+window.__nextChannelId = 0;
|
|
|
|
+window.__channels = [];
|
|
|
|
+
|
|
export class WebDioxusChannel extends DioxusChannel {
|
|
export class WebDioxusChannel extends DioxusChannel {
|
|
js_to_rust: Channel;
|
|
js_to_rust: Channel;
|
|
rust_to_js: Channel;
|
|
rust_to_js: Channel;
|
|
owner: any;
|
|
owner: any;
|
|
|
|
+ id: number;
|
|
|
|
|
|
constructor(owner: any) {
|
|
constructor(owner: any) {
|
|
super();
|
|
super();
|
|
this.owner = owner;
|
|
this.owner = owner;
|
|
this.js_to_rust = new Channel();
|
|
this.js_to_rust = new Channel();
|
|
this.rust_to_js = new Channel();
|
|
this.rust_to_js = new Channel();
|
|
|
|
+
|
|
|
|
+ this.id = window.__nextChannelId;
|
|
|
|
+ window.__channels[this.id] = this;
|
|
|
|
+ window.__nextChannelId += 1;
|
|
}
|
|
}
|
|
|
|
|
|
// Return a weak reference to this channel
|
|
// Return a weak reference to this channel
|
|
@@ -40,4 +48,9 @@ export class WebDioxusChannel extends DioxusChannel {
|
|
async rustRecv(): Promise<any> {
|
|
async rustRecv(): Promise<any> {
|
|
return await this.js_to_rust.recv();
|
|
return await this.js_to_rust.recv();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Close the channel, dropping it.
|
|
|
|
+ close(): void {
|
|
|
|
+ window.__channels[this.id] = null;
|
|
|
|
+ }
|
|
}
|
|
}
|