📰 IT NachrichtenWhy It’s Difficult for Tech Companies to Rein In A.I.(12.09.2026 um 11:02 Uhr)
🔧 AI Nachrichten Etzioni on AI: What kids tell chatbots, but not you(04.09.2026 um 16:05 Uhr)
🔧 AI Nachrichten OpenAI Wants to Know if an AI Industry Slowdown Would Even Be Legal(11.09.2026 um 01:28 Uhr)
🔧 AI Nachrichten OpenAI puts Pro subscriptions on hold due to Astra demand(10.09.2026 um 22:59 Uhr)
📰 IT NachrichtenWhy It’s Difficult for Tech Companies to Rein In A.I.(12.09.2026 um 11:02 Uhr)
🔧 AI Nachrichten Etzioni on AI: What kids tell chatbots, but not you(04.09.2026 um 16:05 Uhr)
🔧 AI Nachrichten OpenAI Wants to Know if an AI Industry Slowdown Would Even Be Legal(11.09.2026 um 01:28 Uhr)
🔧 AI Nachrichten OpenAI puts Pro subscriptions on hold due to Astra demand(10.09.2026 um 22:59 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 2 Min Lesezeit
0

Using BroadcastChannel API with Vue to sync a ref across multiple tabs

↗ Quelle (dev.to)
🗣️ Stimme:

We try to save time for everyone in our team, not only developers: some people spend a lot of time configuring our app for clients or demos, so we make sure it's as smooth as possible. For instance, we try to make every change real time, so there's no need to reload the app for changes to appear.



Recently, we figured out those people usually work with multiple tabs open, making sure the configuration works as expected in multiple pages of the app. So we thought about syncing the configuration across tabs.



We didn't want to store it, neither in session, local storage or anything else, as we will then have to make sure it's always up to date.



That's when we came across the BroadcastChannel API, I didn't even know it existed. It's not fairly new, but Safari was the last to implement it according to




CODE
const {
isSupported,
channel,
post,
close,
error,
isClosed,
} = useBroadcastChannel({ name: 'unique-name' })






So we created a little in house composable based on it to make sure a ref is always synchronized among all tabs:




CODE
import { useBroadcastChannel, watchPausable } from '@vueuse/core';
import { nextTick, watch } from 'vue';

import type { Ref } from 'vue';

export const useSync = <T>(value: Ref<T>, name: string, options?: { immediate?: boolean; deep?: boolean }) => {
// Name must be unique
const { post, data } = useBroadcastChannel<T, T>({ name });

// When value changes locally, update other tabs
const { pause, resume } = watchPausable(
() => value.value,
(newValue) => {
post(structuredClone(newValue));
},
options,
);

// When value changes in another tab, update it locally
watch(
() => data.value,
async (newValue) => {
// Prevent watch loop when updating config
pause();
value.value = newValue;
await nextTick();
resume();
},
options,
);
};






So now we can sync a ref with a single line:




CODE
const config = ref({})
useSync(config, 'config', { deep: true });






And voilà! That's some hours saved each month across teams 🥳

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
5 Quellen
Rockwell Automation FactoryTalk Activation Manager
3 Quellen
September-Patchday: Adobe schließt kritische Zero-Day-Lücke und 172 weitere
2 Quellen
Jetzt patchen! Angreifer attackieren JFrog Artifactory und machen sich zu Admins
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Using BroadcastChannel API with Vue to sync a ref across multiple tabs

Thematisch verwandte Begriffe: Using, BroadcastChannel, with, sync · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...