Skip to content

Instantly share code, notes, and snippets.

View kamaladenalhomsi's full-sized avatar
😀
CRAFTING

Kamal Eddin kamaladenalhomsi

😀
CRAFTING
View GitHub Profile
@kamaladenalhomsi
kamaladenalhomsi / traditional-way-to-fetch-and-store-data-vuex.js
Created January 13, 2021 12:33
Traditional way to fetch and store data in vuex
const state => () => ({
cats: {
loaded: false,
data: []
}
})
const mutations = {
SET_CATS (state, payload) {
// merge payload with state
@kamaladenalhomsi
kamaladenalhomsi / viewState.js
Created January 14, 2021 08:32
ViewState.js
import { isFunction } from './helpers'
const GET_KEY = 'get'
const PUSH_KEY = 'PUSH_TO_'
const SET_KEY = 'SET_'
function mergeWithViewState (state, payload) {
Object.keys(payload).forEach(key => {
state[key] = payload[key]
})