반응형
Vuex의 다른 작업 내에서 작업을 디바운스할 수 없음
행동 안에 있는 모든 것을 밝히려고 하는데, 어떤 식으로든 삼켜버리면...
다음 (의사) 코드를 사용합니다.
import { debounce } from "lodash";
const actions = {
debounceSomeLogging ({ dispatch }, text) {
console.log("Outside debounced function.");
debounce(function() {
console.log("Inside debounced function.");
dispatch("doRealThing");
}, 1000);
},
doRealThing({ commit }) {
// Whatever
}
}
액션을 호출하면Outside debounced function
단, 다른 로깅은 표시되지 않으며 다른 액션은 트리거되지 않습니다.
이 일을 경험하신 분 중에 저를 올바른 방향으로 인도해 주실 수 있는 분 계십니까?
이것은 일을 정의해야 한다.
import { debounce } from "lodash";
const actions = {
debounceSomeLogging: debounce(({ dispatch }, text) => {
console.log("Inside debounced function.");
dispatch("doRealThing");
}, 1000),
doRealThing({ commit }) {
// Whatever
}
}
Nemesv가 댓글에서 지적했듯이debounce
함수가 내부 함수를 호출하지 않습니다.다시 데바운스를 호출해야 합니다.
debounce(function() {
console.log("Inside debounced function.");
dispatch("doRealThing");
}, 1000)();
요컨대 다음과 같습니다.
debounce(...)()
이렇게 하는 대신debounce(...)
.
언급URL : https://stackoverflow.com/questions/53977241/can-not-debounce-action-within-other-action-in-vuex
반응형
'programing' 카테고리의 다른 글
SVG가 vue-svg-loader를 로드하고 있습니다.[ Vue warn ] :잘못된 구성 요소 정의 (0) | 2022.06.03 |
---|---|
집합을 목록으로 변환하는 가장 간결한 방법 (0) | 2022.06.03 |
Tomcat, JBoss, Glassfish의 차이점은 무엇입니까? (0) | 2022.06.03 |
현지화된 텍스트에서 vue별 지시어를 사용할 수 있습니까? (0) | 2022.06.03 |
Vue.js: 이벤트버스가 여러 번 호출됨 (0) | 2022.06.03 |