Get the App
SLTechnology News&Howtos  ›  Development  › 

Event processing queue Analysis of Angular and SAP C4C

Shulou Source: shulou.com Published: 2022-06-02 16:35:14 11月15日 Update

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!

Tags: Events queues processing elements loops analysis functions properties code content learning utility deeper tasks interests variables but handlers practicality reality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei MariaDB OPPO Reno Shulou Technology