Skip to content

Instantly share code, notes, and snippets.

@foxbunny
Last active November 21, 2018 14:05
Show Gist options
  • Save foxbunny/2c5a9d0448fe1b7508a986ca7f1a765c to your computer and use it in GitHub Desktop.
Save foxbunny/2c5a9d0448fe1b7508a986ca7f1a765c to your computer and use it in GitHub Desktop.
Imba-Vue adapter for using Imba apps inside Vue
import Vue from 'vue'
import { Component, Prop } from 'vue-property-decorator'
import Imba from 'imba'
/**
import { App } from './App.imba'
import ImbaAdapter from './ImbaAdapter'
...
<ImbaAdapter tag={App} data={{some: 'data'}} />
*/
@Component
class ImbaAdapter extends Vue {
@Prop({ required: true }) tag
@Prop() data
mounted() {
this._tag = Imba.createElement(this.tag)
if (this.data) this._tag.setData(this.data)
Imba.mount(this._tag.end(), this.$refs.root)
}
beforeDestroy() {
Imba.TagManager.unmount(this._tag)
}
render(h) {
return h('div', { ref: 'root' })
}
}
export default ImbaAdapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment