Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add promise gesture #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add promise gesture #16

wants to merge 2 commits into from

Conversation

szaccaria
Copy link

Suppose that the "func" has inside it a promise.
Like this example:

var debounceUpdateEntity = debounce(function(entity) {
    $http.put('/resource/entity/entity.id, entity, {
    }).then(function(response) {
        entity.version = response.data.version;
    }, function() {
    })['finally'](function() {
        debounceUpdateEntity.endPromise();
    });
}, waitDebouceTime, false, true, true);

I would that until the promise not have finish his work, the debounce func was not called

For you this is correct?

Suppose that the "func" has inside it a promise.
Like this example: 

var debounceUpdateEntity = debounce(function(entity) {
		$http.put('/resource/entity/entity.id, entity, {

		}).then(function(response) {
			entity.version = response.data.version;
		}, function() {

		})['finally'](function() {
			debounceUpdateEntity.endPromise();
		});
	}, waitDebouceTime, false, true, true);

I would that until the promise not have finish his work, the debounce func was not called

For you this is correct?
@shahata
Copy link
Owner

shahata commented Dec 16, 2015

Why not just do something like

var blocking = false;
var fn = debounce(() => {
  if (!blocking) {
    blocking = true;
    $http.put(...).finally(() => blocking = false);
  }
}, waitDebounceTime);

@szaccaria
Copy link
Author

Because i don't think about it :) Your solution seem to work like I want. I must test it.
Thanks for give me the attention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants