admin管理员组文章数量:1125976
the problem is i have to long delay between FE and BE, on the code you can see console.time: console.time('frontEnd archive') === 20000ms and console.time('archive back'); === 40ms.
I have the function on the FE side:
const { electron, RecipeService, MachineService, dialog } = window;
const handleArchiveRecipe = useCallback(async () => {
try {
if (selectedRecipe) {
console.time('frontEnd archive');
await RecipeService.archiveOne(selectedRecipe._id);
console.timeEnd('frontEnd archive');
resetSelect();
getRecipesFunc().catch(console.error);
}
} catch (err) {
const typedError = err as { message: string };
console.error(typedError);
ShowNotification(typedError.message);
}
}, [selectedRecipe]);
BE side:
contextBridge.exposeInMainWorld('RecipeService', RecipeService);
export const RecipeService: IRecipeService = {
archiveOne: async (id: string) => Service.archiveOne(id),
}
class Service {
static async archiveOne(id: string) {
console.time('archive back');
const data = await ipcRenderer.invoke('findById', id, undefined);
if (data.recipe) {
const recipe = new Recipe();
recipe.initPouchRecipe(data.recipe.versions, data.recipe.metadata);
recipe.versions.forEach((v) => {
recipe.currentVersionArchivation(v, true, getUserName());
});
const res = ipcRenderer.invoke('updateOne', data._id, data._rev, { recipe });
console.timeEnd('archive back');
return res;
}
throw new Error("Couldn't find the recipe");
}
}
i have to long delay between FE and BE. I don't know how to fix it, please help me.
I try to reinstall the deps. Also on this project i am working with another developer and we both use windows and he doens't have this problem
本文标签: reactjselectron contextBridge works too slowlyStack Overflow
版权声明:本文标题:reactjs - electron contextBridge works too slowly - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736651283a1946146.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论