Sliding window: constant notification count #
This property checks that the notification count doesn’t
change — that it is the same as in the first state. Note how
this property evaluates notificationCount.current
in the outer thunk, and then uses that in the inner thunk to
compare against the current value.
import { extract, always, now, time } from "@antithesishq/bombadil";
export * from "@antithesishq/bombadil/browser/defaults";
const notificationCount = extract((state) =>
state.document.body.querySelectorAll(".notification").length,
);
export const constantNotificationCount = now(() => {
const initial = notificationCount.current;
return always(() =>
notificationCount.current === initial,
);
});