Created
September 11, 2022 15:51
-
-
Save gushogg-blake/5fcfeebf535ac92c2a843d5d32cf8bb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let app = getContext("app"); | |
let { | |
tabs, | |
selectedTab, | |
} = app; | |
function select({detail: tab}) { | |
app.selectTab(tab); | |
} | |
function close({detail: tab}) { | |
app.closeTab(tab); | |
} | |
function reorder({detail: {tab, index}}) { | |
app.reorderTab(tab, index); | |
} | |
function updateTabs() { | |
tabs = app.tabs; | |
} | |
async function onSelectTab() { | |
selectedTab = app.selectedTab; | |
} | |
onMount(function() { | |
let teardown = [ | |
app.on("updateTabs", updateTabs), | |
app.on("selectTab", onSelectTab), | |
app.on("document.save", updateTabs), | |
app.on("document.edit", updateTabs), | |
app.on("document.fileChanged", updateTabs), | |
]; | |
return function() { | |
for (let fn of teardown) { | |
fn(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment