Up until the current API version (4.23), the refresh method on refreshable layers returns void.
I think it would be useful if the method got converted to a promise so developers can react when the refresh is successful or has failed.
For the moment, I have implemented something that notifies me when the refresh is done regardless of the fact that it has succeeded or failed.
new Promise<void>((resolve, reject) => {
layer.refresh();
view.whenLayerView(layer)
.then((layerView) => whenFalseOnce(layerView, "updating", () => resolve()))
.catch((reason) => reject(reason));
})
The main goal would be to react when a refresh on a layer has failed.