Commit 9ade85b5 authored by NzSN's avatar NzSN

update connect and disconnect

parent ec6b7258
......@@ -72,20 +72,25 @@ export class WW extends Observable {
* 2.No datas from targetWW will be streamed to current WW.
* 3.If a WW is be connected already then the connection
* between them is remain effective. */
connect(targetWW) {
connect(targetWW, install, predict) {
if (targetWW.ident in this.#connected) {
// Already connected no effect
return;
}
let sub = this.subscribe(data => {
targetWW.postMessage(data);
});
install(targetWW);
let sub = this.pipe(filter(data => predict(data)))
.subscribe(data => { targetWW.postMessage(data); });
this.#connected[targetWW.ident] = sub;
}
disconnect(targetWW) {
disconnect(targetWW, uninstall) {
uninstall(targetWW);
if (targetWW.ident in this.#connected) {
this.#connected[targetWW.ident].unsubscribe();
delete this.#connected[targetWW.ident];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment