Using DOM Future

25 views
Skip to first unread message

Jake Archibald

unread,
May 21, 2013, 3:36:51 AM5/21/13
to requestau...@chromium.org
Feels like requestAutocomplete should return a Future (http://dom.spec.whatwg.org/#futures) rather than 'autocomplete' & 'autocompleteerror'

Eg, instead of

button.addEventListener('click', function(){
   form.requestAutocomplete();
});

// see details on event handling below
form.addEventListener('autocomplete', function(){
  // successful rAc
  // Call your client-side form validation logic here, if you have any.
  form.submit();  // trigger submit
});

form.addEventListener('autocompleteerror', function(){
  // event.reason is one of "cancel", "invalid" or "disabled".
  // handle error...
});

The equivalent would be:

button.addEventListener('click', function() {
  form.requestAutocomplete().then(function() {
    // successful rAc
    // Call your client-side form validation logic here, if you have any.
    form.submit();  // trigger submit
  }, function(reason) {
    // reason is one of "cancel", "invalid" or "disabled".
    // handle error...
  });
});

All future async succeed/fail methods should be / are heading in this direction.

Cheers,
Jake.

Alex Komoroske

unread,
May 21, 2013, 11:16:30 AM5/21/13
to Jake Archibald, requestau...@chromium.org, Alex Russell, Elliott Sprehn
[+ Alex Russell, Futures taskmaster, and Elliott]


--
You received this message because you are subscribed to the Google Groups "requestAutocomplete" group.
To unsubscribe from this group and stop receiving emails from it, send an email to requestautocomp...@chromium.org.
To post to this group, send email to requestau...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/requestautocomplete/?hl=en.
 
 

Albert Bodenhamer

unread,
May 22, 2013, 12:50:16 PM5/22/13
to Jake Archibald, requestautocomplete
Thanks for bringing that up Jake.

The current design is flexible enough to allow us to move to Futures later if that's the right thing to do.  Right now, it's a bit early to make that call.



On Tue, May 21, 2013 at 12:36 AM, Jake Archibald <jakear...@chromium.org> wrote:

--
You received this message because you are subscribed to the Google Groups "requestAutocomplete" group.
To unsubscribe from this group and stop receiving emails from it, send an email to requestautocomp...@chromium.org.
To post to this group, send email to requestau...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/requestautocomplete/?hl=en.
 
 



--
Albert Bodenhamer | Software Engineer | abodenha@chromium.org 
Reply all
Reply to author
Forward
0 new messages