Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 [experiment] signals unwatch (issue) v2 #118

Open
wants to merge 3 commits into
base: check-signals
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on:
push:
branches:
- master
- check-signals
pull_request:
branches: [master]
branches: [master, check-signals]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@
"@glimmer/syntax": "^0.87.1",
"content-tag": "^1.2.2",
"decorator-transforms": "1.1.0",
"signal-polyfill": "^0.1.0"
"signal-polyfill": "0.1.2"
}
}
10 changes: 6 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/utils/signals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const w = new Signal.subtle.Watcher(() => {
scheduleRevalidate();
});

export let signalsToUnwatch: Signal.Computed<any>[] = [];
export function setResolveRender(value: () => void) {
resolveRender = value;
}
Expand Down Expand Up @@ -36,6 +37,7 @@ export async function syncDom() {
w.getPending().forEach((cell) => {
cell.get();
});
w.unwatch(...signalsToUnwatch);
w.watch();
setIsRendering(false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { isFn } from './shared';
import { Signal } from "signal-polyfill";

import { w } from './signals';
import { signalsToUnwatch, w } from './signals';
type maybeDestructor = undefined | (() => void);
type maybePromise = undefined | Promise<void>;

Expand Down Expand Up @@ -98,6 +98,6 @@ export function opcodeFor(tag: AnyCell, op: tagOp) {
w.watch(computed);
computed.get();
return () => {
w.unwatch(computed);
signalsToUnwatch.push(computed);
};
}
Loading