Public
Edited
Feb 28, 2023
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {Vue} from "@unluckyninja/vue"
Insert cell
Vue
Insert cell
Insert cell
Insert cell
view1 = {
const ele = htl.html`<div />` // document.createElement('div')
Vue.createApp({
template: '<p>"Hello, world!"</p>',
}).mount(ele)
return ele
}
Insert cell
view1
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable time = 0
Insert cell
updateTime = ()=>{
mutable time = Date.now()
}
Insert cell
Insert cell
{
invalidation.then(()=>{
updateTime()
})
return md`Click run button on this cell will trigger it.`
}
Insert cell
Insert cell
time
Insert cell
invalInOtherCell = (text)=>{
invalidation.then(()=>{
updateTime()
})
return text || md`Click run button on this cell will trigger it.`
}
Insert cell
invalInOtherCell(md`Notice \`time\` doesn\'t change if you rerun this cell`)
Insert cell
Insert cell
{
return Generators.observe(notify=>{
notify(md`Click run button on this cell will trigger it.<br> This works in referencing cell`) // value that should be returned by the cell
return ()=>{ updateTime() } // invalidation hook
})
}
Insert cell
time
Insert cell
generatorsInOtherCell = (text)=>{
return Generators.observe(notify=>{
notify(text || md`Click run button on this cell will trigger it.<br> This works in referencing cell`) // value that should be returned by the cell
return ()=>{ updateTime() } // invalidation hook
})
}
Insert cell
generatorsInOtherCell(md`Notice \`time\` changed.`)
Insert cell
Insert cell
time
Insert cell
generatorObject(md`Rerun this cell.`)
Insert cell
generatorObject = (text)=>{
let done = false
return {
next(){
if (done) return {done: true};
done = true;
return {done: false, value: text};
},
return(){
updateTime()
}
}
}
Insert cell
Insert cell
Insert cell
testVueApp('Check your browser console. No matter how many time you run this cell, it should be only one logger at a time')
Insert cell
testVueApp = (text)=>{
const ele = htl.html`<div />`
let app = Vue.createApp({
template: `<p>${text}</p>`,
setup(){
const handle = setInterval(()=>{
console.log('Beep')
}, 1000)
return {
handle
}
},
unmounted(){
console.log('Unmounted!')
clearInterval(this.handle)
}
})
app.mount(ele)
return Generators.observe(notify=>{
notify(ele)
return ()=>{ app.unmount() }
})
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
unocss = import('https://cdn.jsdelivr.net/npm/@unocss/runtime/uno.global.js')
Insert cell
<div class="p-2 bg-blue"><div class="p-2 text-yellow border-solid border-red rounded">123123</div></div>
Insert cell
Insert cell
Insert cell
Insert cell
createVueApp = (componentOptions, callback)=>{
const ele = htl.html`<div />`
let oldInstance = typeof callback === 'function' ? callback() : callback
let app = typeof componentOptions === 'function' ? Vue.createApp(componentOptions(oldInstance)) : Vue.createApp(componentOptions)
app.mount(ele)
return Generators.observe(notify=>{
notify(ele)
return ()=>{ app.unmount() }
})
}
Insert cell
import {toc} from "@nebrius/indented-toc"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more