I am currently working on a part of our application that will display a subset of topo data under certain circumstances. I am trying to test part of that functionality but I am currently unable to get my code to run in a test.
I am quite new to the esri stack and particularly front end testing so it is possible I'm doing something wrong or misunderstanding a concept, however a lot of trial and error and Google searching hasn't turned anything up.
At the most basic level my issue is that I can't get the watcher created by a reactiveUtils instance to trigger.
I have a MapView that is passed into my function I then have code that looks like this
Hi @Tom_Prutz, Good evening,
I don't know whether your question is still relevant, as you posted it almost 2 weeks ago...
Actually I think your code snippet should work, so we have got to find out why it is not working - as you say - in your case. You can find more information about reactiveUtils in the ArcGIS JS API Reference, and there it is suggested to put a question mark behind view. But I did test your sample without a question mark, and that did the job as well...
reactiveUtils.when(
() => view?.stationary === true,
() => {
console.log("view is stationary now");
});
To see a working example you have a look at this blogpost ArcGIS JavaScript with UK data - URL.searchParams. It might seem an older post, but I just updated it tonight, to use reactiveUtils (instead of the deprecated, and now even completely removed, watchUtils which I used in an earlier version of the post). As you can see, the parameters in the URL are updated every time the view becomes stationary.
So, in the end, the conclusion might be, that your issue is caused by your test setup. Can you please provide us with more information/code to explain what you are trying to do?
Cheers,
Egge-Jan
Thank you for coming back to me. I had to pivot a bit as I ran out of ideas and with the help of an Esri consultant we did manage to get it working by mocking out the reactiveUtils so from a practical stand point this is now resolved.
I suspect you may have been correct about the test setup and I will bear that in mind for the future. Many Thanks.