Lazy load platform specific code
Differential Revision: D3369528 fbshipit-source-id: 0fbc63fbac5e96468598fb3d0a86c6b20f96f39d
This commit is contained in:
parent
1f2027a1fe
commit
c55e3649dd
|
@ -12,10 +12,17 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Platform = {
|
const Platform = {
|
||||||
OS: 'android',
|
OS: 'android',
|
||||||
get Version() { return require('NativeModules').AndroidConstants.Version; },
|
get Version() { return require('NativeModules').AndroidConstants.Version; },
|
||||||
select: (obj: Object) => obj.android,
|
select: (obj: Object) => obj.android,
|
||||||
|
lazySelect(obj: ?Object): ?Object {
|
||||||
|
if (!obj || !obj.android) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.android();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Platform;
|
module.exports = Platform;
|
||||||
|
|
|
@ -12,9 +12,16 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Platform = {
|
const Platform = {
|
||||||
OS: 'ios',
|
OS: 'ios',
|
||||||
select: (obj: Object) => obj.ios,
|
select: (obj: Object) => obj.ios,
|
||||||
|
lazySelect(obj: ?Object): ?Object {
|
||||||
|
if (!obj || !obj.ios) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.ios();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Platform;
|
module.exports = Platform;
|
||||||
|
|
Loading…
Reference in New Issue