} } document.addEventListener("visibilitychange", onVisibilityChange); const unsubscribe = store.subscribe(function () { // This is the key operation of this class, to prevent notification // when the panel is hidden. if (document.visibilityState == "visible") { listener(); } }); // Calling `subscribe` should return an unsubscribe function return function () { unsubscribe(); document.removeEventListener("visibilitychange", onVisibilityChange); }; }, // Provide expected default store functions getState() { return store.getState(); }, dispatch(action) { return store.dispatch(action); }, }; } exports.visibilityHandlerStore = visibilityHandlerStore; PK