nl_tokens: @function initialize @memberOf mobile - angular - ui . core . sharedState~SharedState @description
pl_tokens: 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 [ <mask> ] . 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 ] ; } ) ; }