flowify some Libraries
This commit is contained in:
parent
d0d6dbffb3
commit
18b6d5c20d
|
@ -7,6 +7,7 @@
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule NativeModules
|
* @providesModule NativeModules
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule RCTAlertManager
|
* @providesModule RCTAlertManager
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule RCTEventEmitter
|
* @providesModule RCTEventEmitter
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule RCTJSTimers
|
* @providesModule RCTJSTimers
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule CameraRoll
|
* @providesModule CameraRoll
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -28,7 +29,8 @@ var GROUP_TYPES_OPTIONS = [
|
||||||
'SavedPhotos', // default
|
'SavedPhotos', // default
|
||||||
];
|
];
|
||||||
|
|
||||||
deepFreezeAndThrowOnMutationInDev(GROUP_TYPES_OPTIONS);
|
// Flow treats Object and Array as disjoint types, currently.
|
||||||
|
deepFreezeAndThrowOnMutationInDev((GROUP_TYPES_OPTIONS: any));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape of the param arg for the `getPhotos` function.
|
* Shape of the param arg for the `getPhotos` function.
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule RCTDeviceEventEmitter
|
* @providesModule RCTDeviceEventEmitter
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*
|
*
|
||||||
* @providesModule Geolocation
|
* @providesModule Geolocation
|
||||||
|
* @flow
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -33,7 +34,10 @@ var updatesEnabled = false;
|
||||||
*/
|
*/
|
||||||
var Geolocation = {
|
var Geolocation = {
|
||||||
|
|
||||||
getCurrentPosition: function(geo_success, geo_error, geo_options) {
|
getCurrentPosition: function(
|
||||||
|
geo_success: Function,
|
||||||
|
geo_error?: Function,
|
||||||
|
geo_options?: Object) {
|
||||||
invariant(
|
invariant(
|
||||||
typeof geo_success === 'function',
|
typeof geo_success === 'function',
|
||||||
'Must provide a valid geo_success callback.'
|
'Must provide a valid geo_success callback.'
|
||||||
|
@ -45,7 +49,7 @@ var Geolocation = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
watchPosition: function(success, error, options) {
|
watchPosition: function(success: Function, error?: Function, options?: Object): number {
|
||||||
if (!updatesEnabled) {
|
if (!updatesEnabled) {
|
||||||
RCTLocationObserver.startObserving(options || {});
|
RCTLocationObserver.startObserving(options || {});
|
||||||
updatesEnabled = true;
|
updatesEnabled = true;
|
||||||
|
@ -64,15 +68,17 @@ var Geolocation = {
|
||||||
return watchID;
|
return watchID;
|
||||||
},
|
},
|
||||||
|
|
||||||
clearWatch: function(watchID) {
|
clearWatch: function(watchID: number) {
|
||||||
var sub = subscriptions[watchID];
|
var sub = subscriptions[watchID];
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
// Silently exit when the watchID is invalid or already cleared
|
// Silently exit when the watchID is invalid or already cleared
|
||||||
// This is consistent with timers
|
// This is consistent with timers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub[0].remove();
|
sub[0].remove();
|
||||||
sub[1] && sub[1].remove();
|
// array element refinements not yet enabled in Flow
|
||||||
|
var sub1 = sub[1]; sub1 && sub1.remove();
|
||||||
subscriptions[watchID] = undefined;
|
subscriptions[watchID] = undefined;
|
||||||
var noWatchers = true;
|
var noWatchers = true;
|
||||||
for (var ii = 0; ii < subscriptions.length; ii++) {
|
for (var ii = 0; ii < subscriptions.length; ii++) {
|
||||||
|
@ -90,9 +96,12 @@ var Geolocation = {
|
||||||
RCTLocationObserver.stopObserving();
|
RCTLocationObserver.stopObserving();
|
||||||
updatesEnabled = false;
|
updatesEnabled = false;
|
||||||
for (var ii = 0; ii < subscriptions.length; ii++) {
|
for (var ii = 0; ii < subscriptions.length; ii++) {
|
||||||
if (subscriptions[ii]) {
|
var sub = subscriptions[ii];
|
||||||
|
if (sub) {
|
||||||
warning('Called stopObserving with existing subscriptions.');
|
warning('Called stopObserving with existing subscriptions.');
|
||||||
subscriptions[ii].remove();
|
sub[0].remove();
|
||||||
|
// array element refinements not yet enabled in Flow
|
||||||
|
var sub1 = sub[1]; sub1 && sub1.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
subscriptions = [];
|
subscriptions = [];
|
||||||
|
|
Loading…
Reference in New Issue