Last active
November 21, 2018 14:05
-
-
Save foxbunny/2c5a9d0448fe1b7508a986ca7f1a765c to your computer and use it in GitHub Desktop.
Imba-Vue adapter for using Imba apps inside Vue
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
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