[Common UI] Add in-line docs for Browse

Add in-line docs for bundle platform/commonUI/browse,
which implements Browse mode, one of the common user
interface bundles being transitioned in WTD-574.
This commit is contained in:
Victor Woeltjen
2014-11-25 16:53:22 -08:00
parent b97e2d0324
commit 36fab50825
8 changed files with 116 additions and 39 deletions

View File

@ -9,17 +9,20 @@ define(
"use strict";
/**
*
* The navigation service maintains the application's current
* navigation state, and allows listening for changes thereto.
* @constructor
*/
function NavigationService() {
var navigated,
callbacks = [];
// Getter for current navigation
function getNavigation() {
return navigated;
}
// Setter for navigation; invokes callbacks
function setNavigation(value) {
navigated = value;
callbacks.forEach(function (callback) {
@ -27,10 +30,12 @@ define(
});
}
// Adds a callback
function addListener(callback) {
callbacks.push(callback);
}
// Filters out a callback
function removeListener(callback) {
callbacks = callbacks.filter(function (cb) {
return cb !== callback;
@ -38,9 +43,30 @@ define(
}
return {
/**
* Get the current navigation state.
*/
getNavigation: getNavigation,
/**
* Set the current navigation state. Thiswill invoke listeners.
* @param {DomainObject} value the domain object to navigate
* to
*/
setNavigation: setNavigation,
/**
* Listen for changes in navigation. The passed callback will
* be invoked with the new domain object of navigation when
* this changes.
* @param {function} callback the callback to invoke when
* navigation state changes
*/
addListener: addListener,
/**
* Stop listening for changes in navigation state.
* @param {function} callback the callback which should
* no longer be invoked when navigation state
* changes
*/
removeListener: removeListener
};
}