Skip to content

Instantly share code, notes, and snippets.

View AlanJenkinsVS's full-sized avatar

Alan Jenkins AlanJenkinsVS

View GitHub Profile
@AlanJenkinsVS
AlanJenkinsVS / ComponentRegistration.js
Created April 16, 2018 15:16
2. Component Registration - Vue JS Optimisations
/*
* Loads components from this directory with the name format of 'base-{name}.vue'.
* Components are registered globally.
* Note - don't do this for every component as this will bloat your bundles
*/
import Vue from 'vue';
import upperFirst from 'lodash/upperFirst';
import camelCase from 'lodash/camelCase';
@AlanJenkinsVS
AlanJenkinsVS / SmarterWatchers.js
Created April 16, 2018 15:04
1. Smarter Watchers - Vue JS Optimisations
// Typical pattern
created() {
this.fetchUserList();
},
watch: {
searchText() {
this.fetchUserList();
}
}
(function(window){
window.vs = window.vs || {};
window.vs.debounce = window.vs.debounce || debounce;
// Snatched debounce function from underscore.js
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;