Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Event processing queue Analysis of Angular and SAP C4C

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "event handling queue Analysis of Angular and SAP C4C". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn the event handling queue analysis of Angular and SAP C4C.

Angular

We can see a function called processQueue in the code of the Angular framework:

This function is passed through the

Apply initiated:

The core code is in a for loop, the body of which is a queue asyncQueuePosition that stores asynchronous processing tasks:

For (var asyncQueuePosition = 0; asyncQueuePosition)

< asyncQueue.length; asyncQueuePosition++) {try { asyncTask = asyncQueue[asyncQueuePosition]; fn = asyncTask.fn; fn(asyncTask.scope, asyncTask.locals);} catch (e) { $exceptionHandler(e);} lastDirtyWatch = null;} 队列里每个元素长这样的:一个处理函数fn,一个局部变量locals和scope对象: 这个注释也非常有用:一旦Angular发现由

It appears again in the JavaScript execution sequence triggered by apply

A nested call to apply throws an error message: $digest already in progress

/ / It's safe for asyncQueuePosition to be a local variable here because this loop can't

/ / be reentered recursively. Calling evalAsync would

/ / lead to a'$digest already in progress' error.

C4C event queue

The event handler of C4C, EventProcessor.js has an event queue:

The implementation of the queue is located in the OperationQueue.js of sap/client/evt/:

A random click on C4C UI can trigger EventProcessor's _ processQueue,C4C event queue in the same way as Angular, except that a while loop replaces Angular's for loop:

Each element in the C4C event queue has the following attributes, which can be compared with the Angular event element:

FFunc is equivalent to the fn attribute of the Angular time element, and environment is equivalent to the scope attribute of the Angular event element.

At this point, I believe you have a deeper understanding of "event handling queue Analysis of Angular and SAP C4C". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report