Sap.ui.require in SAP UI5 and require in Nodejs

Source: Internet
Author: User

UI5

For example, I need to messagetoast a message in the controller's Onshowhello to display it on the UI,

I need to define my own controller first, the controller extend from the UI5 standard controller module, the path is Sap/ui/core/mvc/controller, In order to invoke Messagetoast's Show method, you must first get the Messagetoast instance. So UI5 uses Sap.ui.define to load the two dependent module, and after the load is done, it invokes the callback function passed by the application developer, and the contents of the two module loaded are passed into the callback function as two input parameters.

UI5 All module is managed by the module in Jquery.sap.global.js.

For more details please see my former colleague of Sap Wu Ji blog SAPUI5 walkthrough step 6–modules, Dive in–how does modules work?

There is, of course, sap.ui.require this concise usage. An example of the use of a UI5 framework:

Nodejs

Logic and UI5 are similar, assuming that I want to use the QueryString module, just use the NODEJS standard require function to introduce it:

This module can then be used in the application code to expose a method through Module.exports:

Require calls the Self.require in Internal/module.js:

Then the module._load:

Nodejs also has Module unified manager similar to UI5: Module._cache. Each time the module is loaded, first check from this manager if the module is already loaded. Only when the module does not exist in the manager will it actually load, new a module object, maintain the good attributes and then save the module manager.

A loaded module is a collection of function:


To get more original Jerry's technical articles, please follow the public number "Wang Zixi" or scan the QR code below:

Sap.ui.require in SAP UI5 and require in Nodejs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.