Annotate Clipboard module

Reviewed By: svcscm

Differential Revision: D2866837

fb-gh-sync-id: 0f7da139e1296aec6a518d52056a6d0a1b9c07ca
shipit-source-id: 0f7da139e1296aec6a518d52056a6d0a1b9c07ca
This commit is contained in:
Satyajit Sahoo 2016-02-15 10:04:45 -08:00 committed by facebook-github-bot-5
parent 51a8b54015
commit 46a8f1d8e0
1 changed files with 11 additions and 10 deletions

View File

@ -7,10 +7,12 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Clipboard
* @flow
*/
'use strict';
var Clipboard = require('NativeModules').Clipboard;
const Clipboard = require('NativeModules').Clipboard;
const deprecatedCallback = require('deprecatedCallback');
/**
* `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
@ -24,14 +26,13 @@ module.exports = {
* }
* ```
*/
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;
}
return Clipboard.getString();
getString(): Promise<string> {
return deprecatedCallback(
Clipboard.getString(),
Array.prototype.slice.call(arguments),
'success-first',
'Clipboard.getString(callback) is deprecated. Use the returned Promise instead'
);
},
/**
* Set content of string type. You can use following code to set clipboard content
@ -42,7 +43,7 @@ module.exports = {
* ```
* @param the content to be stored in the clipboard.
*/
setString(content) {
setString(content: string) {
Clipboard.setString(content);
}
};