From 747be0bf5cd1f9953312c40e3099b5eb0a58de08 Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Thu, 21 Jan 2016 09:48:47 -0800 Subject: [PATCH] Change the js signature to be Promise based and dynamically detect it used as a callback Summary: Making the default people see when they look at the module the Promise based version public Reviewed By: davidaurelio Differential Revision: D2850048 fb-gh-sync-id: e0815983ed798c202047cb071e65ce63a52fd1af --- Examples/UIExplorer/ClipboardExample.js | 3 ++- Libraries/Components/Clipboard/Clipboard.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Examples/UIExplorer/ClipboardExample.js b/Examples/UIExplorer/ClipboardExample.js index 0adfdd6f5..fa2814a2a 100644 --- a/Examples/UIExplorer/ClipboardExample.js +++ b/Examples/UIExplorer/ClipboardExample.js @@ -28,6 +28,7 @@ var ClipboardExample = React.createClass({ content: 'Content will appear here' }; }, + async _setClipboardContent(){ Clipboard.setString('Hello World'); try { @@ -36,8 +37,8 @@ var ClipboardExample = React.createClass({ } catch (e) { this.setState({content:e.message}); } - }, + render() { return ( diff --git a/Libraries/Components/Clipboard/Clipboard.js b/Libraries/Components/Clipboard/Clipboard.js index 0abc57010..9b3ef5950 100644 --- a/Libraries/Components/Clipboard/Clipboard.js +++ b/Libraries/Components/Clipboard/Clipboard.js @@ -23,10 +23,10 @@ module.exports = { * var content = await Clipboard.getString(); * } * ``` - * @param this parameter is deprecated. callback is function with one argument of string type */ - getString(callback) { - if (callback) { + getString() { + if (arguments.length > 0) { + let callback = arguments[0]; console.warn('Clipboard.getString(callback) is deprecated. Use the returned Promise instead'); Clipboard.getString().then(callback); return;