riot-js

Open full view…

How to access the 'back button' route/event?

skwny
Mon, 19 Dec 2016 21:36:40 GMT

I'm using the riot router for my project, and when I use the back button, it takes me to the correct location. However, I recently learned that I will need to execute some code when this occurs. The reason for this is that I have a video conferencing tool that will continue to run when the back button is pressed (i.e. camera and microphone are still engaged and publishing), and I need to shut it down when the user navigates away from the page. I can do this with normal routing, but with back button I do not know how. What's the technique to use in this case? Thanks.

jonaspm
Mon, 06 Feb 2017 06:10:36 GMT

route(to[, title, shouldReplace]) With the third argument, you can replace the current history. It’s useful when the app needs redirect to another page. route('not-found', 'Not found', true) Internally… -without shouldReplace, history.pushState() will be used. -with shouldReplace, history.replaceState() will be used.

skwny
Mon, 06 Feb 2017 21:48:57 GMT

Thank you very much for the response jonaspm!

jonaspm
Tue, 07 Feb 2017 00:52:41 GMT

you're welcome skwny ;) I hope it helps you.