Skip to content

Example of unplugin-auto-expose main-to-renderer pattern? #921

Answered by cawa-93
TheAutomaTom asked this question in Q&A
Discussion options

You must be logged in to vote

I feel you kind a missed up in renderer part. You export onLoadProjectFile from preload but don't import it in renderer. (BTW I also don't see reasons to listen DOMContentLoaded in onMounted hook) Perhaps you means:

// App.vue
import { onLoadProjectFile } from '#preload' // <-- 

import type { Project } from "./../../ipc-models/Takeoff/Takeoff";
const project = ref({ projectName: "Unloaded Project", projectClient: "Unloaded Client" } as Project);
onMounted( async () => {
  window.addEventListener("DOMContentLoaded", () => {
    onLoadProjectFile((_, value) => { // <--
      project.value = value;
    });
  });
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TheAutomaTom
Comment options

Answer selected by TheAutomaTom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants