UNPKG

@discoveryjs/discovery

Version:

Frontend framework for rapid data (JSON) analysis, shareable serverless reports and dashboards

20 lines (19 loc) 752 B
import { createLocationSync } from "../core/utils/location-sync.js"; export default function(host) { function createHostLocationSync() { return createLocationSync((hash) => host.setPageHash(hash), host.logger); } let locationSync = createHostLocationSync(); host.setPageHash(location.hash); host.cancelScheduledRender(); host.action.define("permalink", (hash) => new URL(hash, String(location)).href); host.action.define("setPreventLocationUpdate", (prevent = true) => { if (prevent) { locationSync?.dispose(); locationSync = null; } else if (locationSync === null) { locationSync = createHostLocationSync(); } }); host.on("pageHashChange", (replace) => locationSync?.set(host.pageHash, replace)); }