diff --git a/example/fake-window.html b/example/fake-window.html new file mode 100644 index 00000000..4eaf1070 --- /dev/null +++ b/example/fake-window.html @@ -0,0 +1,164 @@ + + +
++ Welcome to the JSChannel fake window example page. View source and you'll + get an idea of how you can use Channel.buildFactory() to use jschannel + as a generic RPC mechanism that's not limited to cross-document messaging. +
+ +First, here is basic function invocation: + + +Next, here's error handling: + + +Next, here's notification output: + + +Finally, here's callback invocation output: + + + + + + diff --git a/src/jschannel.js b/src/jschannel.js index a57d00f3..7241d70f 100644 --- a/src/jschannel.js +++ b/src/jschannel.js @@ -37,8 +37,9 @@ */ ;var Channel = (function() { - "use strict"; +"use strict"; +var buildFactory = function buildFactory(window) { // current transaction id, start out at a random *odd* number between 1 and a million // There is one current transaction counter id per page, and it's shared between // channel instances. That means of all messages posted from a single javascript @@ -611,4 +612,11 @@ return obj; } }; +}; + +var Channel = buildFactory(window); +Channel.buildFactory = buildFactory; + +return Channel; + })();