Created
June 3, 2016 11:07
-
-
Save havvg/b6a3a81f88f53a9215ac328db34d1369 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 eventBus = new Vue() | |
new Vue({ | |
el: '#application', | |
replace: true, | |
template: '<app :event-bus="eventBus" :websocket-url="websocketUrl"></app>', | |
data: { | |
eventBus: eventBus, | |
websocketUrl: websocketUrl | |
} | |
}); |
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
<template> | |
<div> | |
<log-entry v-for="entry in entries" :entry="entry" :event-bus="eventBus"></log-entry> | |
</div> | |
</template> | |
<script> | |
import LogEntry from './components/log-entry.vue' | |
import {levels} from './data/log-levels.js' | |
export default { | |
props: [ | |
'eventBus', | |
'websocketUrl' | |
], | |
data() { | |
return { | |
websocket: null, | |
entries: [] | |
} | |
}, | |
methods: { | |
removeEntry(entry) { | |
// .. | |
} | |
}, | |
created() { | |
this.eventBus.$on('remove-entry', this.removeEntry) | |
}, | |
components: { | |
LogEntry | |
} | |
} | |
</script> |
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
<template> | |
<div> | |
<a href="#" @click="removeEntry(entry)"><i class="fa fa-remove"></i></a> | |
</div> | |
</template> | |
<script> | |
export default { | |
props: [ | |
'entry', | |
'eventBus' | |
], | |
methods: { | |
removeEntry: function(entry) { | |
this.eventBus.$emit('remove-entry', entry) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment