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

How do you cancel job1 completely before its timeout value occur? #1374

Closed
arthurevans opened this issue Apr 7, 2015 · 9 comments
Closed
Assignees

Comments

@arthurevans
Copy link

From @gertcuykens on December 27, 2014 3:17

https://www.polymer-project.org/docs/polymer/polymer.html#job

this.responseChanged = function() {
  this.job('job1', function() { // first arg is the name of the "job"
    this.fire('done');
  }, 500);
}

Copied from original issue: Polymer/old-docs-site#847

@arthurevans arthurevans added the 0.8 label Apr 7, 2015
@arthurevans
Copy link
Author

From @ebidel on December 27, 2014 17:29

job() is for debouncing. Presumably you want whatever you're wrapping to be called at least once. If you want a cancelable call, try async() which can be canceled using cancelAsync():

cancelAsync: function(handle) {

We need to document this method: Polymer/old-docs-site#848

@arthurevans
Copy link
Author

From @gertcuykens on December 27, 2014 18:26

Let say you have a hover in and hover out where the hover toaster get a delay before it disappears after a hover out. But when you hover back in quick enough you need to cancel that job of disappearing.

The thing about async() is that it doesn't cancel itself when you hover in out in multiple times before the timeout like job() does?

@arthurevans
Copy link
Author

From @gertcuykens on December 27, 2014 21:12

Currently I do it like this

            in: function (e){
                this.cancel=true
                document.querySelector('my-hover').fire('my-hover-in', {'title': title})
            },

            out: function (e){
                this.cancel=false
                this.job('myJob', function() {
                    if (this.cancel) return 0
                    document.querySelector('my-hover').fire('my-hover-out')
                }, 500);
            },

But this would be nicer

            in: function (e){
                this.jobCancel('myJob')
                document.querySelector('my-hover').fire('my-hover-in', {'title': title})
            },

            out: function (e){
                this.job('myJob', function() {
                    document.querySelector('my-hover').fire('my-hover-out')
                }, 500);
            },

@arthurevans
Copy link
Author

A little code poking reveals an alternate way of invoking job, using a job handle instead of a string. You can use the handle to stop the job, like this:

this.myjob = this.job(this.myjob, function);
this.myjob.stop();

Big caveat -- this syntax may be deprecated:

// TODO(sjmiles): suggest we deprecate this call signature

https://github.com/Polymer/polymer/blob/master/src/lib/job.js#L41

It would be pretty trivial to add a cancelJob method. What say you, @sjmiles ?

@arthurevans
Copy link
Author

From @gertcuykens on December 30, 2014 22:56

Great thanks, I would never tought of that

PS Actually I would deprecate this part haha :)

var n = '___' + job;
this[n] = Polymer.job.call(this, this[n], callback, wait);

not the following part because it is nicer and does not mess with polymer internals.

return Polymer.job.call(this, job, callback, wait);

@arthurevans
Copy link
Author

From @ebidel on April 6, 2015 16:50

This issue has gone stale. Marking as obsolete.

@arthurevans
Copy link
Author

From @gertcuykens on April 6, 2015 19:15

I am happy the github issues are getting cleaned up. I know you all have things to do and I also know allot of them are invalid, but still every open issue is a frustrated user and every polymer team member should know that even it is not there fault.

@arthurevans
Copy link
Author

Talked to core folks. I'm going to re-open and move this to Polymer/polymer as an 0.8 feature request.

@sorvell
Copy link
Contributor

sorvell commented May 22, 2015

this.cancelDebouncer('name')

@sorvell sorvell closed this as completed May 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants