Last active
December 19, 2017 16:36
-
-
Save Elevista/0e25177e57053e06764b7250db3816e0 to your computer and use it in GitHub Desktop.
lodash로 vue 모델의 배열을 다룰때 뮤테이션 감지를 시키기 위해 기본 함수를 래핑합니다.
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
let lodash = _.runInContext() | |
export let wrapLodashArrForVue = _(['pull', 'pullAll', 'pullAllBy', 'pullAllWith', 'pullAt', 'remove']) | |
.map(fnName => { | |
let fn = lodash[fnName] | |
return [ | |
fnName, | |
function (v, …args) { | |
let ret = fn(v, …args) | |
if (v instanceof Array) v.push() | |
return ret | |
}] | |
}) | |
.fromPairs() | |
.value() | |
// -------------------------------------------------------------------- | |
import { wrapLodashArrForVue } from './vueLodashArray' | |
_.mixin(wrapLodashArrForVue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment