Skip to content

Commit

Permalink
Change the js signature to be Promise based and dynamically detect it…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Dave Miller authored and facebook-github-bot-7 committed Jan 21, 2016
1 parent c888e65 commit 747be0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Examples/UIExplorer/ClipboardExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var ClipboardExample = React.createClass({
content: 'Content will appear here'
};
},

async _setClipboardContent(){
Clipboard.setString('Hello World');
try {
Expand All @@ -36,8 +37,8 @@ var ClipboardExample = React.createClass({
} catch (e) {
this.setState({content:e.message});
}

},

render() {
return (
<View>
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Components/Clipboard/Clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

1 comment on commit 747be0b

@mkonicek
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

Please sign in to comment.