Skip to content

Vue migration: Update extension/sidebar.js (bridge to Vue store) #33

@exhuma

Description

@exhuma

Part of #19.\n\nThe current sidebar.js sets element.links = JSON.stringify(response) directly on the custom element DOM node. With a Vue SPA the app is self-contained, so a different bridge is needed.\n\nApproach: dispatch a custom DOM event that the Vue app listens for:\n\njs\n// sidebar.js\nfunction onBookmarksRetrieved(response) {\n document.dispatchEvent(\n new CustomEvent('schmackhaft:bookmarks-loaded', {\n detail: JSON.stringify(response)\n })\n )\n}\n\n\nts\n// App.vue (onMounted)\ndocument.addEventListener('schmackhaft:bookmarks-loaded', (e) => {\n store.setLinks(e.detail)\n})\n\n\nThe bookmarksModified handler stays the same (calls refreshBookmarks()).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions