The "hwc" Namespace

The SAP Mobile Platform JavaScript API implementation emulates the namespace concept.

JavaScript does not use the concept of a true namespace, but you can achieve the same result by placing functions and objects with a new function. (This is often called a "JavaScript Namespace" for simplicity). The SAP Mobile Platform implementation uses the JavaScript "Immediately-Invoked Function Expression" (IIFE—pronounced "iffy" like in "jiffy") pattern to contain the SAP Mobile Platform API in the global object named "hwc". The "hwc" object provides a lexical scope, which is the JavaScript shorthand for what other languages term a "namespace".

This lexical scope isolates the SAP Mobile Platform API (in the same way as a namespace) and provides tools for minification and other processes. This change is reflected throughout the code. A few JavaScript functions have proxy versions in the global namespace; however SAPĀ® recommends that you use the versions in the "hwc" namespace.

We have attempted to not move code around unnecessarily, to facilitate developers using "difference scans" to identify changes, and to understand where to place their existing customizations.

In many cases, you need only wrap the entire contents of a file with the "hwc" object definition. The files that have more extensive changes are described in later topics.