I would strongly suggest updating to version 2.9.0 which holds the new viewer implementation and API. The documentation is here.
The version you are currently on is what is known as the “old” viewer. Starting with 2.9 the viewer went through a big rework on all levels. Moving forward we will continue to build upon the 2.9 foundations. Please note that after updating you might see some breaking changes.
Regarding your original question, I see you explicitly call the viewer’s render function. You don’t need to do that. The viewer runs it’s own update/render loop. You can however run your own update loop in parallel if you have the need. Currently the viewer does not expose any explicit callbacks or events for when the viewer is rendering/updating but we will add such mechanisms in the future. If you update to ver 2.9, you won’t need to do anything in order to signal a re-render of the viewer since that version is using continuous rendering. This however will change in future updates, the API will have proper mechanisms for requesting a render along with update/render hooking.