28 lines
663 B
JavaScript
28 lines
663 B
JavaScript
import {inject, provide, watch} from "vue";
|
|
|
|
const injectKey = 'webDjPassthroughSync';
|
|
|
|
export function useProvidePassthroughSync (passthroughSync) {
|
|
provide(injectKey, passthroughSync);
|
|
}
|
|
|
|
export function useInjectPassthroughSync() {
|
|
return inject(injectKey);
|
|
}
|
|
|
|
export function usePassthroughSync(thisPassthrough, stringVal) {
|
|
const passthroughSync = useInjectPassthroughSync();
|
|
|
|
watch(passthroughSync, (newVal) => {
|
|
if (newVal !== stringVal) {
|
|
thisPassthrough.value = false;
|
|
}
|
|
});
|
|
|
|
watch(thisPassthrough, (newVal) => {
|
|
if (newVal) {
|
|
passthroughSync.value = stringVal;
|
|
}
|
|
});
|
|
}
|