Created
July 6, 2014 16:43
-
-
Save oslego/3813910f4b3b2eee704f to your computer and use it in GitHub Desktop.
Mock impl of chrome.runtime for static development
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
/* | |
Mock-implementation of chrome.runtime messaging API | |
*/ | |
var Messager = (function (){ | |
var _listeners = []; | |
return { | |
onMessage: { | |
addListener: function(cb){ | |
_listeners.push(cb); | |
} | |
}, | |
postMessage: function(data){ | |
_listeners.forEach(function(cb){ | |
cb.call(this, data); | |
}); | |
} | |
}; | |
})(); | |
chrome.runtime.connect = function(){ | |
return Messager; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment