[RxJS] Extend Promises by Adding Custom Behavior
by Rxjs Custom extend adding Behavior promises
2023-09-14 08:59:14 时间
We will create a Promise wrapper, that can be used instead of normal promises, to track different tasks that we need to show the spinner for.
export class PromiseWithLoadingProgress extends Promise { constructor(callback) { super((originalResolve, originalReject) => { const resolveSpy = (...args) => { originalResolve(...args); existingTaskCompleted(); }; const rejectSpy = (...args) => { originalReject(...args); existingTaskCompleted(); }; callback(resolveSpy, rejectSpy); }); newTaskStarted(); } } const doVeryQuickWork = () => { new PromiseWithLoadingProgress(resolve => { setTimeout(() => { resolve(); }, 300); }); }; const doAlmostQuickWork = () => { new PromiseWithLoadingProgress(resolve => { setTimeout(() => { resolve(); }, 2200); }); };
相关文章
- elasticsearch 5.x Delete By Query API(根据条件删除)
- mysql 排序 oder by 和 使用hibernate 排序
- [React] Avoid this Common Suspense Gotcha in by Reading Data From Components
- [RxJS] Implement RxJS `switchMap` by Canceling Inner Subscriptions as Values are Passed Through
- [RxJS] Avoid mulit post requests by using shareReplay()
- [rxjs] Creating An Observable with RxJS
- [Bootstrap] install Bootstrap framework in window 7 by npm
- 中文模糊查询性能优化 by PostgreSQL trgm
- [RxJS 6] The Retry RxJs Error Handling Strategy
- [RxJS] Avoid mulit post requests by using shareReplay()
- [RxJS] Hot Observable, by .share()
- [AngularJS] Directive using another directive by 'require'
- Atitit table的读取解析from html by jsoup java html paresr 目录 1. atitit.gui控件的定位与选择器1 2. 读取表格流程 遍历表格ta
- Unity技术手册 - 生命周期内大小(Size over Lifetime)和速度决定大小(Size by Speed)
- 【关于ChatGPT的30个问题】29、是否有其他与ChatGPT类似的人工智能系统?/ By 禅与计算机程序设计艺术
- Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but L...
- oracle record is locked by another user
- nginx conf by linux kernel
- Linux QtCreator 编译报错:No rule to make target '.../***' needed by '***.o'.stop
- 网站设计师:Nicepage 4.15 Crack By Xacker
- 【YOLOv7/YOLOv5系列算法改进NO.48】构建新的轻量网络—Slim-neck by GSConv(2022CVPR)