Elemental2 doesn't support all calls?

55 views
Skip to first unread message

Craig Mitchell

unread,
Aug 14, 2025, 7:03:39 PMAug 14
to GWT Users
The opening statement of Elemental2 says "Elemental2 provides type checked access to all browser APIs for Java code."

I went to use navigator.vibrate ( https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate ) and found Elemental2 doesn't have it.

Does anyone know why it's not there?

Craig Mitchell

unread,
Aug 14, 2025, 8:47:13 PMAug 14
to GWT Users
btw:  This isn't a big deal, as JSInterop can easily do it:

import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public interface NavigatorVibrate {
  @JsMethod
  boolean vibrate(double milliseconds);
  @JsMethod
  boolean vibrate(double[] pattern);
}

NavigatorVibrate nav = Js.cast(DomGlobal.navigator);
nav.vibrate(80);

Just found it odd that this one thing (maybe others too?) is missing.

Thomas Broyer

unread,
Aug 19, 2025, 8:33:03 AMAug 19
to GWT Users
Elemental2 is generated from the Closure Library definitions (with some overrides), so first Closure needs to be updated to include it, then Elemental2 needs to pick up the changes (assuming they are in a file that Elemental2 looks at; so sometimes Elemental2 build needs to be updated)

Craig Mitchell

unread,
Aug 19, 2025, 6:42:29 PMAug 19
to GWT Users
Thanks Thomas.

I see w3c_vibration.js in the closure-compiler:  https://github.com/google/closure-compiler/blob/master/externs/browser/w3c_vibration.js

So it looks like the Elemental2 build needs to be updated to use w3c_vibration.js.

Reply all
Reply to author
Forward
0 new messages