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
import { createStore } from 'vuex'; | |
// The modules to import | |
import auth, { Store as AuthStore, State as AuthState } from './auth'; | |
import counter, { Store as CounterStore, State as CounterState } from './counter'; | |
// A State type with all the submodules | |
type State = { | |
auth: AuthState; | |
counter: CounterState; |
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
/** | |
* I'll update this gist as I get to define more helpful methods to extend | |
*/ | |
/** | |
* insertReplace, looks for unique keys on the table and the data to insert | |
* if the current key/value pair is found (and unique) update it with the given data, | |
* otherwise insert it as a new record | |
*/ | |
db.Table.prototype.insertReplace = function(data) { |
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
// Usually I use this in my app's config file, in case I need to disable all cache from the app | |
// Cache is from `js-cache`, something like `import Cache from 'js-cache';` | |
const cacheable = true, | |
cache = new Cache(); | |
// On request, return the cached version, if any | |
axios.interceptors.request.use(request => { | |
// Only cache GET requests | |
if (request.method === 'get' && cacheable) { |
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
/** | |
* Note: this is an updated version of the original plugin: | |
* https://gist.github.com/fnlctrl/1cf9da63493e0fe78181a4f4e2cc6f64 | |
* | |
* VueRouteData plugin for [email protected] and vue@1or2, | |
* implemented according to https://github.com/vuejs/vue-router/issues/296#issuecomment-235481643 | |
* | |
* This plugin looks for `$options.fetchRouteData`, | |
* and watches `$route` using `$options.fetchRouteData` as handler. | |
* |