2019-10-15 03:00:57 +00:00
|
|
|
// the page-lifecycle package causes some problems (doesn't work in node),
|
|
|
|
// and plus it's not needed immediately, so lazy-load it
|
2019-10-30 01:58:49 +00:00
|
|
|
import { importPageLifecycle } from './asyncModules/importPageLifecycle.js'
|
2019-10-15 03:00:57 +00:00
|
|
|
|
|
|
|
function addEventListener (event, func) {
|
|
|
|
if (process.browser) {
|
|
|
|
importPageLifecycle().then(lifecycle => {
|
|
|
|
lifecycle.addEventListener(event, func)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeEventListener (event, func) {
|
|
|
|
if (process.browser) {
|
|
|
|
importPageLifecycle().then(lifecycle => {
|
|
|
|
lifecycle.removeEventListener(event, func)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const lifecycle = { addEventListener, removeEventListener }
|