Ding-Log
  • Ding Blog
  • Life
    • My Tool Box
  • Golang
    • Basic
      • Go语言学习笔记
        • Go语言 Channel
        • Go语言 goroutine
        • Go语言 如何写Godoc
        • Go语言panic, recover
        • Go语言的Defer函数
        • Go语言的闭包
        • Go语言接口(Golang - Interface)
        • Go语言的面向对象
      • Go语言爬虫
        • Go语言爬虫 - 广度优先算法
      • Map
    • Web
      • Example to handle GET and POST request in Golang
    • Exercism
      • Isogram
      • ETL
      • Accumulate
      • Scrabble Score
  • SAP
    • SAPUI5&Fiori
      • How to prepare C_FIORDEV_20 SAP Certified Development Associate — SAP Fiori Application Developer
      • SAPUI5 sap.ui.define and sap.ui.require
      • SAPUI5 Models and Binding
      • SAPUI5 MVC Walkthrough
    • ABAP
      • Working with Internal Tables
      • 关于使用内部表的时候的一些注意事项
      • Error Handling
  • Log
Powered by GitBook
On this page
  • Simple Conclusion
  • Why
  • Function Definition
  • Define
  • Require
  • Example

Was this helpful?

  1. SAP
  2. SAPUI5&Fiori

SAPUI5 sap.ui.define and sap.ui.require

PreviousHow to prepare C_FIORDEV_20 SAP Certified Development Associate — SAP Fiori Application DeveloperNextSAPUI5 Models and Binding

Last updated 6 years ago

Was this helpful?

If you are a beginner of SAPUI5. you may be confused about the difference between sap.ui.define and sap.ui.require.

Simple Conclusion

  • sap.ui.define global namespace for your module and load dependent modules. (Define Module)

  • sap.ui.require load dependent modules without declaring a namespace synchronously. (Call Module)

Why

sap.ui.define and sap.ui .require are the same as in RequireJS. They are both provided to load module.

In javascript, There is no built-in module feature and there are 2 popular concept for modularization.

Concept

Feature

CommonJS

  • Node.js

  • Server Side

  • Compact Syntax

  • synchronous loading

Asynchronous module definition(AMD)

  • Browser

  • complicated syntax

  • asynchronous loading

Because SAPUI5 runs in the browser, sap use the AMD concept.(I doubt that...)

Function Definition

sap.ui.define(sModuleName?, aDependencies?, vFactory, bExport?) : void
sap.ui.require(vDependencies, fnCallback?, fnErrback?) : any|undefined

Example

You can check this video for detail.

If you change the SomeModule's define to Require. It would load the file but you will get error because it's not defined.

Define
Require