Last active
September 28, 2020 19:58
-
-
Save visiongeist/a38efc91426787da8648 to your computer and use it in GitHub Desktop.
Revisions
-
visiongeist revised this gist
Aug 11, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -116,7 +116,7 @@ Granite.author.EditorFrame.postMessage(msg, data, timeout); **Request callback and Response message** ```javascript /** * Function to directly respond to a request. * The function call is attached to the request object @@ -139,7 +139,7 @@ mc.subscribeRequestMessage('a-msg', function (request) { **Promise resolution** ```javascript Promise.then(function (result) { console.log(result.req); // request console.log(result.res); // response -
visiongeist revised this gist
Aug 11, 2015 . 1 changed file with 28 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -114,33 +114,42 @@ Granite.author.EditorFrame.postMessage(msg, data, timeout); ``` **Request callback and Response message** ```javscript /** * Function to directly respond to a request. * The function call is attached to the request object * * @param msg {String} respond message * @param [data] * @param [error] {String} if error occurs */ request.respond(msg, data, error); ``` e.g. ```javascript var mc = new MessageChannel('my-group'); mc.subscribeRequestMessage('a-msg', function (request) { request.respond('my-answer', { some: 'data' }); }); ``` **Promise resolution** ``` Promise.then(function (result) { console.log(result.req); // request console.log(result.res); // response }); Promise.catch(function (result) { console.log(result.req); // request console.log(result.res); // response - null if a timeout occured console.log(result.error); // error message }); ``` -
visiongeist revised this gist
Aug 11, 2015 . 1 changed file with 84 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,54 @@ # AEM 6.2 Authoring Editor to Site messaging API ## API ```javascript /** * * @param group {String} group identifier name * @param [targetWindow=window.parent] * @param [origin='*'] * @constructor */ Granite.author.MessageChannel(group, targetWindow, origin); /** * subscribe to a request message * * @param msg identifier * @param callback */ Granite.author.MessageChannel.prototype.subscribeRequestMessage(msg, callback); /** * unsubscribe a request message * * @param msg identifier * @param callback */ Granite.author.MessageChannel.prototype.unsubscribeRequestMessage(msg, callback); /** * this function will send a message to the content frame * * @param msg {String} message identifier * @param data {Object} Plain JSON object with data to transfer * @param timeout {Number} if the promise should time out, * the default (= 0) is infinite * a negative timeout will not expect any response * @return {Promise} null if the timeout is negative */ Granite.author.MessageChannel.prototype.postMessage(msg, data, timeout); /** * Add configured functionality to another object * @param obj target */ Granite.author.MessageChannel.prototype.mixin(obj); ``` ## in Authoring context ### Editor ```javascript /** @@ -27,13 +75,13 @@ Granite.author.ContentFrame.unsubscribeRequestMessage(msg, callback); * @param timeout {Number} if the promise should time out, * the default (= 0) is infinite * a negative timeout will not expect any response * @return {Promise} null if the timeout is negative */ Granite.author.ContentFrame.postMessage(msg, data, timeout); ``` ### Site ```javascript /** @@ -60,8 +108,39 @@ Granite.author.EditorFrame.unsubscribeRequestMessage(msg, callback); * @param timeout {Number} if the promise should time out, * the default (= 0) is infinite * a negative timeout will not expect any response * @return {Promise} null if the timeout is negative */ Granite.author.EditorFrame.postMessage(msg, data, timeout); ``` **Request callback** ```javascript function (req) { { 'id': this.id, 'group': self._group, 'type': 'response', 'error': error, 'msg': msg, 'data': data || {} } } ``` **Respond call** ``` req.respond() ``` **Promise data** ``` Promise.then(function (result)); Promise.catch(function (result)); ``` -
visiongeist revised this gist
Aug 7, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ Granite.author.ContentFrame.unsubscribeRequestMessage(msg, callback); * a negative timeout will not expect any response * @return {jQuery.Promise} null if the timeout is negative */ Granite.author.ContentFrame.postMessage(msg, data, timeout); ``` @@ -62,6 +62,6 @@ Granite.author.EditorFrame.unsubscribeRequestMessage(msg, callback); * a negative timeout will not expect any response * @return {jQuery.Promise} null if the timeout is negative */ Granite.author.EditorFrame.postMessage(msg, data, timeout); ``` -
visiongeist created this gist
Aug 7, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ # AEM 6.2 Authoring Editor to Site messaging API ## Editor ```javascript /** * subscribe to a request message * * @param msg identifier * @param callback */ Granite.author.ContentFrame.subscribeRequestMessage(msg, callback); /** * unsubscribe a request message * * @param msg identifier * @param callback */ Granite.author.ContentFrame.unsubscribeRequestMessage(msg, callback); /** * this function will send a message to the content frame * * @param msg {String} message identifier * @param data {Object} Plain JSON object with data to transfer * @param timeout {Number} if the promise should time out, * the default (= 0) is infinite * a negative timeout will not expect any response * @return {jQuery.Promise} null if the timeout is negative */ Granite.author.ContentFrame.postMessage(msg, data, timeout) ``` ## Site ```javascript /** * subscribe to a request message * * @param msg identifier * @param callback */ Granite.author.EditorFrame.subscribeRequestMessage(msg, callback); /** * unsubscribe a request message * * @param msg identifier * @param callback */ Granite.author.EditorFrame.unsubscribeRequestMessage(msg, callback); /** * this function will send a message to the content frame * * @param msg {String} message identifier * @param data {Object} Plain JSON object with data to transfer * @param timeout {Number} if the promise should time out, * the default (= 0) is infinite * a negative timeout will not expect any response * @return {jQuery.Promise} null if the timeout is negative */ Granite.author.EditorFrame.postMessage(msg, data, timeout) ```