I'm finally getting around to replacing these calls with Elemental2.
To replace the JSNI method:
public static native void initialise() /*-{
$wnd.onpopstate = $entry(function(e) {
@com.blah.YourClass::yourMethodThatListensForUrlChange()();
});
}-*/;
I would have thought it would be:
public static void initialise() {
DomGlobal.window.onpopstate.onInvoke(event -> {
// Do something
});
}
However, that doesn't compile, as onInvoke takes a @JsFunction, not
a @FunctionalInterface. So, I have to do something like this:
public static void initialise() {
DomGlobal.window.addEventListener("popstate", event -> {
// Do something
});
}
Is this correct?
On Friday, 16 October 2020 at 3:40:39 pm UTC+11 Craig Mitchell wrote:
> As Tomas said, not directly with History. It's simple JSNI though:
>
> public static native void updateURL(String newUrl) /*-{
> $wnd.history.pushState(newUrl, "", newUrl);
> }-*/;
>
> public static native void initialise() /*-{
> $wnd.onpopstate = $entry(function(e) {
> @com.blah.YourClass::yourMethodThatListensForUrlChange()();
> });
> }-*/;
>
>
--
You received this message because you are subscribed to the Google Groups "GWT
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/google-web-toolkit/59a9c005-54fe-445f-9d35-d554d5b9039fn%40googlegroups.com.