weather-bar-app
Version:
Weather Bar is a Weather Application that lives in your Menu Bar giving you beautiful access to real-time weather conditions and a generous 15-day forecast.
37 lines (32 loc) • 696 B
JavaScript
const state = {}
const mutations = {
DELETE_FORECAST (state, data) {
if (data.hasOwnProperty('hash_key')) {
delete state[data.hash_key]
}
},
SAVE_FORECAST (state, data) {
if (data.hasOwnProperty('hash_key')) {
state[data.hash_key] = data.forecast
}
}
}
const getters = {
getForecast: (state) => (hashKey) => {
return (state.hasOwnProperty(hashKey)) ? state[hashKey] : null
}
}
const actions = {
deleteForecast ({ commit }, data) {
commit('DELETE_FORECAST', data)
},
saveForecast ({ commit }, data) {
commit('SAVE_FORECAST', data)
}
}
export default {
state,
mutations,
getters,
actions
}