This file contains hidden or 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
actions: { | |
loadBooks({ commit }) { | |
commit('startLoading'); | |
get('/api/books').then((response) => { | |
commit('setBooks', response.data.books); | |
commit('stopLoading'); | |
}); | |
}, | |
}, |
This file contains hidden or 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
mutations: { | |
setName(state, name) { | |
state.name = name; | |
}, | |
}, | |
actions: { | |
setName({ commit }, name) { | |
commit('setName', name); | |
}, | |
}, |
This file contains hidden or 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
// recreation of a computed property | |
const computed = (vm, func) => { | |
vm.$watch( | |
func, | |
null, // callback not used for lazy | |
{ lazy: true }, // lazy means we can just flag as dirty | |
); | |
// eslint-disable-next-line no-underscore-dangle | |
const watcher = vm._watchers[vm._watchers.length - 1]; |
This file contains hidden or 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
mappedTask2: (state, getters) => { | |
const cache = {}; | |
return (id) => { | |
const record = state.tasks[id]; | |
const key = id + record.name; | |
if (!cache[key]) { | |
cache[key] = getters.mappedTask(id); | |
} | |
return cache[key]; | |
}; |
This file contains hidden or 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 moment from 'moment'; | |
import 'moment-timezone'; | |
// Make all fields on `object` hidden (not enumerable) | |
// except any in the whitelist. | |
const hideFields = (object, whitelist) => Object.keys(object) | |
.forEach((field) => { | |
if (!whitelist.includes(field)) { | |
const val = object[field]; | |
Object.defineProperty(object, field, { |
This file contains hidden or 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
// See this in action: https://jsfiddle.net/mikeapr4/t4x0oe9k/ | |
// Queue-orientated solution, will work for large-scale | |
// nesting (50k+), however additional overhead of space (queue) | |
const flatten = A => { | |
const output = [], queue = [...A] | |
while (queue.length > 0) { | |
const entry = queue.shift() | |
if (Array.isArray(entry)) { |
This file contains hidden or 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
var originalSet = Backbone.Model.prototype.set | |
, noConflictPrefix = '$$'; | |
/** | |
* During initial construction, a model | |
* calls set(), but there is also a check | |
* to ensure the reactivity only occurs on construction | |
*/ | |
Backbone.Model.prototype.set = function() { | |
var duringConstruction = (this.changed === null); |
This file contains hidden or 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
/****************************************************************************** | |
* Inquire: a mocking mechanism for RequireJS (v2.1.9 - tightly coupled) * | |
* * | |
* Unversioned * | |
* * | |
* NOTE: Don't use Inquire for anything which modifies global scope! * | |
******************************************************************************/ | |
var inquire; | |
(function(require) { |
This file contains hidden or 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 org.springframework.security.core.AuthenticationException; | |
import org.springframework.security.web.AuthenticationEntryPoint; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import javax.servlet.http.HttpServletResponseWrapper; | |
import java.io.IOException; | |
public class AjaxAwareAuthEntryPointWrapper implements AuthenticationEntryPoint { |