10 out of 15 rated this helpful - Rate this topic

Writing code using the Windows Library for JavaScript (Windows Store apps using JavaScript and HTML)

Purpose

Windows Library for JavaScript has a number of helper functions that you can use to define and extend JavaScript types. When you want to define new types or derive one type from another, you can use the functions in WinJS.Class. When you want to define different scopes for your JavaScript elements, you can use the functions in WinJS.Namespace.

You can also use mixins when you want to add functionality to your types. In JavaScript, mixins are types that are not instantiated and contain members that define a certain kind of behavior that can be added to multiple types. For example, a Movable mixin that contains functions goForward, goBackward, turnRight, and turnLeft can be be mixed into a number of different types, like Vehicle, Robot, and Animal. For more information about mixins, see Mixins.

In this section

TopicDescription

Defining and deriving types with WinJS.Class (Windows Store apps using JavaScript and HTML)

You can use the WinJS.Class.define and WinJS.Class.derive functions to define and derive JavaScript types.

Organizing your code with WinJS.Namespace (Windows Store apps using JavaScript and HTML)

The WinJS.Namespace.define function allows you to create your own namespace as a way of organizing your code.

Adding functionality with WinJS mixins (Windows Store apps using JavaScript and HTML)

Mixins are objects that implement a certain class of functionality. For example, in the Windows Library for JavaScript there are mixins that manage events and mixins that handle binding.

Event capture and event bubbling with DOM events (Windows Store apps using JavaScript and HTML)

In Windows Library for JavaScript there are several addEventListener methods (for example, WinJS.Application.addEventListener and WinJS.UI.AppBar.addEventListener). They all contain a useCapture parameter, which is set to true if you want event capture or false if you want event bubbling. For more information, see see Event capture and Event bubbling.

 

 

 

Build date: 11/15/2012

© 2013 Microsoft. All rights reserved.