This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an instance of our cache and set some keys. Notice that the [new] operator | |
// is optional since the SimpleCache (and revealing module pattern) doesn't use | |
// prototypical inheritance. And, we can use method-chaining to set the cache keys. | |
var cache = SimpleCache() | |
.set( "foo", "Bar" ) | |
.set( "hello", "world" ) | |
.set( "beep", "boop" ) | |
; | |
console.log( cache.has( "beep" ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var MyApp = angular.module('MyApp'); | |
MyApp.factory('msgBus', ['$rootScope', function($rootScope) { | |
var msgBus = {}; | |
msgBus.emitMsg = function(msg, data) { | |
data = data || {}; | |
$rootScope.$emit(msg, data); | |
}; | |
msgBus.onMsg = function(msg, func, scope) { | |
var unbind = $rootScope.$on(msg, func); | |
if (scope) { |