In 4.25 I get this warning
[esri.core.watchUtils]
DEPRECATED - Module: esri/core/watchUtils
️ Replacement: esri/core/reactiveUtils
:gear:Version: 4.24
I have tried to use reactiveUtils but without success, the watchUtils example in
works ok.
Here is the example that works and the other that I'm not able to get to work.
//works!
watchUtils.whenTrue(view.popup,'visible', () => {
watchUtils.whenFalseOnce(view.popup,'visible', () => {
console.info('popup has been closed');
})
});
//doesn't work
reactiveUtils.whenOnce(() => view.popup.visible).then(() => {
reactiveUtils.whenOnce(() => !view.popup.visible).then(() => {
console.info('how to get here?');
})
});
A hybrid solution seems to work but I want to remove 'watchUtils' so it's not an option.
//this hybrid works
reactiveUtils.whenOnce(() => view.popup.visible).then(() => {
watchUtils.whenFalseOnce(view.popup,'visible', () => {
console.info('popup has been closed');
})
});
Any suggestions how to proceed?
Thanks
Solved! Go to Solution.
If you just care about when the popup is closed, you don't need to capture when it's opened. You could, but it just depends on what you want to do.
when(
() => view.popup?.visible,
() => {
whenOnce(() => !view.popup.visible).then(() =>
console.log("Popup closed after opened")
);
}
);
// just capture when it closes
when(
() => !view.popup?.visible,
() => console.log("Popup closed")
);
If you just care about when the popup is closed, you don't need to capture when it's opened. You could, but it just depends on what you want to do.
when(
() => view.popup?.visible,
() => {
whenOnce(() => !view.popup.visible).then(() =>
console.log("Popup closed after opened")
);
}
);
// just capture when it closes
when(
() => !view.popup?.visible,
() => console.log("Popup closed")
);
Thanks! Both of these examples worked fine!😀
This sample shows different ways of using reactiveUtils: https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=watch-for-changes-reacti...
If you want to watch a change only once then you can use reactiveUtils.whenOnce, please take a look at the doc and code snippets: https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html#whenOnce