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
This commit is contained in:
Dave Miller 2016-01-21 09:48:47 -08:00 committed by facebook-github-bot-7
parent c888e6583f
commit 747be0bf5c
2 changed files with 5 additions and 4 deletions

View File

@ -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 (
<View>

View File

@ -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;