chore: replace error emitter with vue.emit

This commit is contained in:
2018-09-17 18:42:44 -07:00
parent 1f2e307f05
commit 3ab623fea1
2 changed files with 9 additions and 18 deletions

View File

@@ -76,8 +76,6 @@
</template>
<script>
import emitter from '../lib/emitter.mjs';
const getMultiValues = node => Array.from(node.selectedOptions).map(o => o.value);
export default {
@@ -86,17 +84,10 @@ export default {
uses: Array,
conditions: Array,
flavors: Array,
error: {
type: String,
default: '',
},
data() {
return {
error: '',
};
},
created() {
emitter.on('error', this.setError);
},
beforeDestroy() {
emitter.off('error', this.setError);
},
methods: {
handleSubmit() {
@@ -108,15 +99,11 @@ export default {
flavors: getMultiValues(this.$refs.flavors),
};
this.error = '';
this.$emit('search', requirements);
},
resetForm() {
this.$el.reset();
},
setError(msg) {
this.error = msg;
},
},
};
</script>

View File

@@ -13,6 +13,7 @@
:uses="uses"
:conditions="conditions"
:flavors="flavors"
:error="error"
@search="onSearch"
/>
</div>
@@ -40,6 +41,7 @@ export default {
},
data() {
return {
error: '',
matches: [],
requirements: {
name: '',
@@ -100,6 +102,8 @@ export default {
this.matches = this.strains.slice(0, limit);
},
updateMatches(limit = 40) {
this.error = '';
if (!this.hasName && !this.hasFilters) {
this.showDefaults(limit);
return;
@@ -127,7 +131,7 @@ export default {
});
} catch (err) {
this.matches = [];
emitter.emit('error', err.message);
this.error = err.message;
}
},
},