Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
Binding addHandlerAsync won't work in parallel
Stan Calisie
0
Reputation points
Greetings! I have a document with around 500 bindings. When my add-in loads it should add handlers for all bindings in the document. I call addHandlerAsync for each binding in an async loop. So, it calls the function around 500 times at the same time. But then I see how handlers are slowly attaching sequentially. Overall it takes about 1 to 3 minutes to attach all handlers. I don't call context.sync() between calls.
So, this affects user experience quite much, so I wonder if there is a workaround. Thank you!
Here's the code snippet:
await each(bindings, ([bindingId, binding]) => {
return new Promise((resolve, reject) => {
binding.addHandlerAsync(
Office.EventType.BindingDataChanged,
this.handleBindingDataChanged,
({ status }) => {
if (status === Office.AsyncResultStatus.Succeeded) {
resolve(true);
} else {
reject(false);
}
}
);
});
});
Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Development | Other
Sign in to answer