f# - Writing handlers for JS.Window.Onpopstate in Websharper -


i'm trying proper back-button support in websharper-app. can put stuff in history fine:

type myrecord = { foo: int; bar: string }  js.window.history.pushstate({foo=10; bar="hello"}, "", "mysuffix") 

i hoping add corresponding handler onpopstate doing this:

js.window.onpopstate <- (fun e -> javascript.console.info e.state.bar) 

unfortunately, event has type js.window.onpopstate : dom.event -> unit , dom.event doesn't have field state getting state, though corresponding "real" javascript event does.

how access state stored pushstate in onpopstate handler?

you can access arbitrary fields objects using dynamic operator ?:

js.window.onpopstate <- (fun e ->     console.info e?state.bar ) 

note still need use [<inline>] call arbitrary method.


Comments

Popular posts from this blog

android - How to save instance state of selected radiobutton on menu -

python 3 IndexError: list index out of range -

IF statement in MySQL trigger -