Created
July 26, 2011 09:12
-
-
Save kwhinnery/1106342 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var os = require('os').os; | |
//branch logic based on platform - saves you an if statement | |
os(function() { | |
alert('do this on android'); | |
}, function() { | |
alert('do this on iOS'); | |
}); | |
var platformSpecificValue = os('android string','ios string'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var osname = Ti.Platform.osname; //grab this once | |
function os(androidValue,iosValue) { | |
if (osname === 'android') { | |
return (typeof androidValue === 'function') ? androidValue() : androidValue; | |
} | |
else { | |
return (typeof iosValue === 'function') ? iosValue() : iosValue; | |
} | |
} | |
exports.os = os; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment