Skip to content

Commit

Permalink
Enhancing cross context caller - now appending event object to method
Browse files Browse the repository at this point in the history
  • Loading branch information
krawaller committed Nov 12, 2010
1 parent c7627e2 commit 05d915a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Resources/tools/cross/cross.html
@@ -1,4 +1,5 @@
<html><head></head>
<html>
<head></head>
<body>
<h1>Cross contexts</h1>
<p>Please check your logs</p>
Expand Down Expand Up @@ -31,4 +32,5 @@ <h1>Cross contexts</h1>
call('app', 'deferred', [2], function(val){ Ti.API.log('webview deferred', val); }); // Should log [WEBVIEW DEFERRED] 5

</script>
</body></html>
</body>
</html>
8 changes: 4 additions & 4 deletions Resources/tools/cross/cross.js
Expand Up @@ -7,8 +7,8 @@

K = global.K = global.K || {};
K.isFunc = function(o){ return toString.call(o) === "[object Function]"; };
K.reg = function(obj, label) {
var lb = '_' + label;
K.reg = function(obj, reglabel) {
var lb = '_' + reglabel;

obj.call = function(label, method, data, callback) {
if(K.isFunc(data) && typeof callback === 'undefined'){
Expand All @@ -20,7 +20,7 @@ K.reg = function(obj, label) {
Ti.App.fireEvent('_' + label, {
method: method,
cid: callback ? cid : false,
source: lb,
source: reglabel,
data: data
});
};
Expand All @@ -43,7 +43,7 @@ K.reg = function(obj, label) {
((typeof (val =
o.apply ? o.apply(
(os[os.length - 2] || obj),
((tmp = (e.data ? (e.data instanceof Array ? e.data : [e.data])[])) && tmp.push(fn) && tmp)
((tmp = (e.data ? (e.data instanceof Array ? e.data : [e.data])[])) && tmp.push(fn) && tmp.push(e) && tmp)
) : o(e.data[0], e.data[1], e.data[2])
) !== 'undefined') && fn(val)) : fn(o);
}
Expand Down

0 comments on commit 05d915a

Please sign in to comment.