符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
这篇文章将为大家详细讲解有关SAP Cloud for Customer里Promise的实际应用场合是怎样的,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
成都创新互联公司是一家专业提供通道企业网站建设,专注与成都做网站、网站制作、H5页面制作、小程序制作等业务。10年已为通道众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。
最近,我正在研究SAP Cloud for Customer的前端代码,我遇到了一个如何在那里使用promise的真实示例。下面是密码登录视图。
Once Passcode is entered, suppose I have already entered the system url and frontend user name in the past, they will be directly retrieved from browser storage.
Currently I use Chrome to access C4C and Web SQL is used as browser storage, where the system url and logon user name could be found from Chrome development tool.
The corresponding database initialization and table read is done by code below in file AppStatusService.js.
The series of callback functions are chained by promise API “then()” which are expected to be executed sequentially:
(1) _createTable() could only be executed after database initialization is done. (2) _getApplicationStatus could NOT be executed unless the database table which stores Application status is available – this is ensured by _createTable. (3) After application status is read from database table, _createDefaultEntries could be called to render the default value in Passcode logon view.
All above three steps are organized by promise to achieve the asynchronous execution mode. In order for me to understand how the above code works, I write a simplified version for illustration:
Open the html page with Chrome, and you can find that a database with name mydb and a table user is created with one record inserted.
In order to achieve the simulation that each step of webSQL is a time-consuming operation, I wrap the real logic into setTimeout with a certain time delay.
I scheduled function work to simulate the main work to do and the database related job are done in an asynchronous way organized within function module setupDB() by promise API.
The console output proves that the database operations are really executed asynchronously in exactly the same order as they are scheduled via then API of promise.
Not all browsers support WebSQL and the specification of WebSQL is no longer in active maintenance.
Even in C4C frontend framework code we can see more and more usage on IndexedDB instead:
关于SAP Cloud for Customer里Promise的实际应用场合是怎样的就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。