W
W
WebDev2018-05-16 12:08:48
Vue.js
WebDev, 2018-05-16 12:08:48

Why is lodash debounce not working in vue?

import _ from 'lodash'
...

created: function() {
    _.debounce(function() {
                console.log('test222');
            }, 500);
},
methods: {
    test: function() {
        _.debounce(function() {
                console.log('test222');
            }, 500);
    }
}

What am I doing wrong? This code doesn't work. At all. However, other methods, such as _.capitalize, work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-05-16
@kirill-93

This code doesn't work. At all.

Of course, everything works. There is a significant difference between "does not work" and "does not work the way I would like". I admit that for you it is elusive, but it is still there. Try to understand it.
test: function() {
    _.debounce(function() {
            console.log('test222');
        }, 500);
}

Presumably, the method itself should have been wrapped in debounce:
test: _.debounce(function() {
  console.log('test222');
}, 500)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question