Check if port is defined before subscribing to avoid error if port is unused.

This commit is contained in:
Dillon Kearns 2022-01-29 09:15:19 -08:00
parent 91c87dd235
commit cfbbf71bf5
2 changed files with 6 additions and 5 deletions

View File

@ -27,7 +27,7 @@ function loadContentAndInitializeApp() {
loadNamedAnchor();
});
app.ports.elmPagesReloadData.subscribe(() => {
app.ports.elmPagesReloadData && app.ports.elmPagesReloadData.subscribe(() => {
console.log("RELOAD DATA PORT!");
app.ports.fromJsPort.send(null);
});

View File

@ -28,10 +28,11 @@ function loadContentAndInitializeApp() {
loadNamedAnchor();
});
app.ports.elmPagesReloadData.subscribe(() => {
console.log("RELOAD DATA PORT!");
app.ports.fromJsPort.send(null);
});
app.ports.elmPagesReloadData &&
app.ports.elmPagesReloadData.subscribe(() => {
console.log("RELOAD DATA PORT!");
app.ports.fromJsPort.send(null);
});
return app;
}