diff --git a/.changeset/clean-chairs-hunt.md b/.changeset/clean-chairs-hunt.md
new file mode 100644
index 00000000..bb38c9ae
--- /dev/null
+++ b/.changeset/clean-chairs-hunt.md
@@ -0,0 +1,5 @@
+---
+"@preact/signals": patch
+---
+
+Gold down the oldNotify capturing
diff --git a/packages/preact/src/index.ts b/packages/preact/src/index.ts
index 2dd9360c..a96f0f43 100644
--- a/packages/preact/src/index.ts
+++ b/packages/preact/src/index.ts
@@ -33,6 +33,17 @@ const HAS_PENDING_UPDATE = 1 << 0;
const HAS_HOOK_STATE = 1 << 1;
const HAS_COMPUTEDS = 1 << 2;
+let oldNotify: (this: Effect) => void,
+ effectsQueue: Array = [],
+ domQueue: Array = [];
+
+// Capture the original `Effect.prototype._notify` method so that we can install
+// custom `._notify`s for each different use-case but still call the original
+// implementation in the end. Dispose the temporary effect immediately afterwards.
+effect(function (this: Effect) {
+ oldNotify = this._notify;
+})();
+
// Install a Preact options hook
function hook(hookName: T, hookFn: HookFn) {
// @ts-ignore-next-line private options hooks usage
@@ -110,7 +121,6 @@ function SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {
};
effect(function (this: Effect) {
- if (!oldNotify) oldNotify = this._notify;
this._notify = notifyDomUpdates;
const val = wrappedSignal.value;
if (isText.value && self.base) {
@@ -254,7 +264,6 @@ function createPropUpdater(
props = newProps;
},
_dispose: effect(function (this: Effect) {
- if (!oldNotify) oldNotify = this._notify;
this._notify = notifyDomUpdates;
const value = changeSignal.value.value;
// If Preact just rendered this value, don't render it again:
@@ -365,10 +374,6 @@ export function useComputed(compute: () => T) {
return useMemo(() => computed(() => $compute.current()), []);
}
-let oldNotify: (this: Effect) => void,
- effectsQueue: Array = [],
- domQueue: Array = [];
-
const deferEffects =
typeof requestAnimationFrame === "undefined"
? setTimeout
@@ -416,7 +421,6 @@ export function useSignalEffect(cb: () => void | (() => void)) {
useEffect(() => {
return effect(function (this: Effect) {
- if (!oldNotify) oldNotify = this._notify;
this._notify = notifyEffects;
return callback.current();
});