dist/js/mobile-angular-ui.core.js
function(scope, id, options) {
          options = options || {};

          var isNewScope = scopes[scope] === undefined;
          var defaultValue = options.defaultValue;
          var exclusionGroup = options.exclusionGroup;

          scopes[scope.$id] = scopes[scope.$id] || [];
          scopes[scope.$id].push(id);

          if (!statusesMeta[id]) { // is a brand new state
            // not referenced by any
            // scope currently

            statusesMeta[id] = angular.extend({}, options, {references: 1});

            $rootScope.$broadcast('mobile-angular-ui.state.initialized.' + id, defaultValue);

            if (defaultValue !== undefined) {
              this.setOne(id, defaultValue);
            }

            if (exclusionGroup) {
              // Exclusion groups are sets of statuses references
              exclusionGroups[exclusionGroup] = exclusionGroups[exclusionGroup] || {};
              exclusionGroups[exclusionGroup][id] = true;
            }

          } else if (isNewScope) { // is a new reference from
            // a different scope
            statusesMeta[id].references++;
          }
          scope.$on('$destroy', function() {
            var ids = scopes[scope.$id] || [];
            for (var i = 0; i < ids.length; i++) {
              var status = statusesMeta[ids[i]];

              if (status.exclusionGroup) {
                delete exclusionGroups[status.exclusionGroup][ids[i]];
                if (Object.keys(exclusionGroups[status.exclusionGroup]).length === 0) {
                  delete exclusionGroups[status.exclusionGroup];
                }
              }

              status.references--;
              if (status.references <= 0) {
                delete statusesMeta[ids[i]];
                delete values[ids[i]];
                $rootScope.$broadcast('mobile-angular-ui.state.destroyed.' + id);
              }
            }
            delete scopes[scope.$id];
          });
        }
function(scope, id, options) {
          options = options || {};

          var isNewScope = scopes[scope] === undefined;
          var defaultValue = options.defaultValue;
          var exclusionGroup = options.exclusionGroup;

          scopes[scope.$id] = scopes[scope.$id] || [];
          scopes[scope.$id].push(id);

          if (!statusesMeta[id]) { // is a brand new state
            // not referenced by any
            // scope currently

            statusesMeta[id] = angular.extend({}, options, {references: 1});

            $rootScope.$broadcast('mobile-angular-ui.state.initialized.' + id, defaultValue);

            if (defaultValue !== undefined) {
              this.setOne(id, defaultValue);
            }

            if (exclusionGroup) {
              // Exclusion groups are sets of statuses references
              exclusionGroups[exclusionGroup] = exclusionGroups[exclusionGroup] || {};
              exclusionGroups[exclusionGroup][id] = true;
            }

          } else if (isNewScope) { // is a new reference from
            // a different scope
            statusesMeta[id].references++;
          }
          scope.$on('$destroy', function() {
            var ids = scopes[scope.$id] || [];
            for (var i = 0; i < ids.length; i++) {
              var status = statusesMeta[ids[i]];

              if (status.exclusionGroup) {
                delete exclusionGroups[status.exclusionGroup][ids[i]];
                if (Object.keys(exclusionGroups[status.exclusionGroup]).length === 0) {
                  delete exclusionGroups[status.exclusionGroup];
                }
              }

              status.references--;
              if (status.references <= 0) {
                delete statusesMeta[ids[i]];
                delete values[ids[i]];
                $rootScope.$broadcast('mobile-angular-ui.state.destroyed.' + id);
              }
            }
            delete scopes[scope.$id];
          });
        }
@function initialize
@memberOf mobile-angular-ui.core.sharedState~SharedState
@description

Initialize, or require if already intialized, a state identified by `id` within the provided `scope`, making it available to the rest of application.

A `SharedState` is bound to one or more scopes. Each time
`initialize` is called for an angular `scope` this will be bound to
the `SharedState` and a reference count is incremented to allow
garbage collection.

Reference count is decremented once the scope is destroyed. When the counter reach 0 the state will be disposed.

@param  {scope} scope The scope to bound this state
@param  {string} id The unique name of this state
@param  {object} [options] Options
@param  {object} [options.defaultValue] the initialization value, it is taken into account only if the state `id` is not already initialized
@param  {string} [options.exclusionGroup] Specifies an exclusion group
for the state. This means that for boolean operations (ie. toggle,
turnOn, turnOf) when this state is set to `true`, any other state
that is in the same `exclusionGroup` will be set to `false`.