Better handling of provide failing

Was having trouble with Vite HMR
This commit is contained in:
thepaperpilot 2022-07-08 08:44:01 -05:00
parent 9b89552f1c
commit 863c70222b
2 changed files with 7 additions and 6 deletions

View file

@ -9,8 +9,10 @@ import { computed, inject, onUnmounted, ref, toRefs, unref, watch } from "vue";
const _props = defineProps<{ id: string }>();
const props = toRefs(_props);
const register = inject(RegisterNodeInjectionKey);
const unregister = inject(UnregisterNodeInjectionKey);
// eslint-disable-next-line @typescript-eslint/no-empty-function
const register = inject(RegisterNodeInjectionKey, () => {});
// eslint-disable-next-line @typescript-eslint/no-empty-function
const unregister = inject(UnregisterNodeInjectionKey, () => {});
const node = ref<HTMLElement | null>(null);
const parentNode = computed(() => node.value && node.value.parentElement);

View file

@ -14,6 +14,7 @@
<script setup lang="ts">
import type { Link } from "features/links/links";
import type { FeatureNode } from "game/layers";
import { BoundsInjectionKey, NodesInjectionKey } from "game/layers";
import { computed, inject, ref, toRef, watch } from "vue";
import LinkVue from "./Link.vue";
@ -23,10 +24,8 @@ const links = toRef(_props, "links");
const resizeListener = ref<Element | null>(null);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const nodes = inject(NodesInjectionKey)!;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const outerBoundingRect = inject(BoundsInjectionKey)!;
const nodes = inject(NodesInjectionKey, ref<Record<string, FeatureNode | undefined>>({}));
const outerBoundingRect = inject(BoundsInjectionKey, ref<DOMRect | undefined>(undefined));
const boundingRect = ref<DOMRect | undefined>(undefined);
watch(
[outerBoundingRect],