refactor(client): extract interval logic to a composable function

あと`onUnmounted`を`onMounted`内で呼んでいたりしたのを修正したりとか
This commit is contained in:
syuilo 2022-06-26 03:12:58 +09:00
parent 6a4574b612
commit 5e95a1f7af
18 changed files with 207 additions and 183 deletions

View file

@ -60,8 +60,10 @@ const onNotification = (notification) => {
}
};
let connection;
onMounted(() => {
const connection = stream.useChannel('main');
connection = stream.useChannel('main');
connection.on('notification', onNotification);
connection.on('readAllNotifications', () => {
if (pagingComponent.value) {
@ -87,10 +89,10 @@ onMounted(() => {
}
}
});
});
onUnmounted(() => {
connection.dispose();
});
onUnmounted(() => {
if (connection) connection.dispose();
});
</script>