Moves common functionality into reusable mixin

This commit is contained in:
Alicia Sykes 2021-12-16 04:53:33 +00:00
parent e0b09d48ee
commit 771e2f3717
13 changed files with 0 additions and 87 deletions

View File

@ -18,9 +18,6 @@ export default {
chartDom: null, chartDom: null,
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* The crypto asset to fetch price data for */ /* The crypto asset to fetch price data for */
asset() { asset() {
@ -61,11 +58,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Create new chart, using the crypto data */ /* Create new chart, using the crypto data */
generateChart() { generateChart() {
return new Chart(`#${this.chartId}`, { return new Chart(`#${this.chartId}`, {

View File

@ -32,9 +32,6 @@ export default {
cryptoData: null, cryptoData: null,
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* The crypto assets to fetch price data for */ /* The crypto assets to fetch price data for */
assets() { assets() {
@ -82,11 +79,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Make GET request to CoinGecko API endpoint */ /* Make GET request to CoinGecko API endpoint */
fetchData() { fetchData() {
axios.get(this.endpoint) axios.get(this.endpoint)

View File

@ -24,9 +24,6 @@ export default {
exchangeRates: null, exchangeRates: null,
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* The users API key for exchangerate-api.com */ /* The users API key for exchangerate-api.com */
apiKey() { apiKey() {
@ -51,11 +48,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Make GET request to CoinGecko API endpoint */ /* Make GET request to CoinGecko API endpoint */
fetchData() { fetchData() {
axios.get(this.endpoint) axios.get(this.endpoint)

View File

@ -43,9 +43,6 @@ export default {
arrivals: [], arrivals: [],
}; };
}, },
mounted() {
this.fetchData();
},
filters: { filters: {
formatDate(date) { formatDate(date) {
const d = new Date(date); const d = new Date(date);
@ -105,11 +102,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Make GET request to CoinGecko API endpoint */ /* Make GET request to CoinGecko API endpoint */
fetchData() { fetchData() {
const requestConfig = { const requestConfig = {

View File

@ -20,9 +20,6 @@ export default {
jokeLine2: null, jokeLine2: null,
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* Language code to fetch jokes for */ /* Language code to fetch jokes for */
language() { language() {
@ -53,11 +50,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Make GET request to Jokes API endpoint */ /* Make GET request to Jokes API endpoint */
fetchData() { fetchData() {
axios.get(this.endpoint) axios.get(this.endpoint)

View File

@ -17,9 +17,6 @@ export default {
chartDom: null, chartDom: null,
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* URL where NetData is hosted */ /* URL where NetData is hosted */
netDataHost() { netDataHost() {

View File

@ -17,9 +17,6 @@ export default {
chartDom: null, chartDom: null,
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* URL where NetData is hosted */ /* URL where NetData is hosted */
netDataHost() { netDataHost() {

View File

@ -13,9 +13,6 @@ import ChartingMixin from '@/mixins/ChartingMixin';
export default { export default {
mixins: [WidgetMixin, ChartingMixin], mixins: [WidgetMixin, ChartingMixin],
components: {}, components: {},
mounted() {
this.fetchData();
},
computed: { computed: {
/* URL where NetData is hosted */ /* URL where NetData is hosted */
netDataHost() { netDataHost() {

View File

@ -42,9 +42,6 @@ export default {
posts: null, posts: null,
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* The URL to users atom-format RSS feed */ /* The URL to users atom-format RSS feed */
rssUrl() { rssUrl() {
@ -91,11 +88,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Make GET request to Rss2Json */ /* Make GET request to Rss2Json */
fetchData() { fetchData() {
axios.get(this.endpoint) axios.get(this.endpoint)

View File

@ -18,9 +18,6 @@ export default {
chartDom: null, chartDom: null,
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* The stock or share asset symbol to fetch data for */ /* The stock or share asset symbol to fetch data for */
stock() { stock() {
@ -66,11 +63,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Create new chart, using the crypto data */ /* Create new chart, using the crypto data */
generateChart() { generateChart() {
return new Chart(`#${this.chartId}`, { return new Chart(`#${this.chartId}`, {

View File

@ -52,11 +52,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Make GET request to CoinGecko API endpoint */ /* Make GET request to CoinGecko API endpoint */
fetchData() { fetchData() {
axios.get(this.endpoint) axios.get(this.endpoint)

View File

@ -49,11 +49,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Makes GET request to the TFL API */ /* Makes GET request to the TFL API */
fetchData() { fetchData() {
axios.get(widgetApiEndpoints.tflStatus) axios.get(widgetApiEndpoints.tflStatus)
@ -114,10 +109,6 @@ export default {
this.showAll = !this.showAll; this.showAll = !this.showAll;
}, },
}, },
created() {
if (this.options.showAll) this.showAll = true;
this.fetchData();
},
}; };
</script> </script>

View File

@ -23,9 +23,6 @@ export default {
comicNum: '', comicNum: '',
}; };
}, },
mounted() {
this.fetchData();
},
computed: { computed: {
/* Let user select which comic to display: random, latest or a specific number */ /* Let user select which comic to display: random, latest or a specific number */
comicNumber() { comicNumber() {
@ -44,11 +41,6 @@ export default {
}, },
}, },
methods: { methods: {
/* Extends mixin, and updates data. Called by parent component */
update() {
this.startLoading();
this.fetchData();
},
/* Make GET request to CoinGecko API endpoint */ /* Make GET request to CoinGecko API endpoint */
fetchData() { fetchData() {
axios.get(this.endpoint) axios.get(this.endpoint)