links-lang / links

Links: Linking Theory to Practice for the Web
http://www.links-lang.org
Other
333 stars 43 forks source link

Redirect command in MVU #1193

Closed SimonJF closed 8 months ago

SimonJF commented 9 months ago

It's often the case that we want to change page as a result of, say, clicking a button in an MVU application. Currently we just use redirect directly as Links is impure, but this isn't a particularly idiomatic way of doing things and has led to a weird race condition in a student project.

This patch introduces a Redirect command, which can be accessed through MvuCommands.changePage(url). The redirect is then processed in the MVU event loop as would be expected.

SimonJF commented 8 months ago

Thanks @dhil. Agreed in general — although since this is in MVU it will run on the client and therefore use the jslib implementation of redirect (which I think uses document.url to perform the redirect).