Skip to content

Instantly share code, notes, and snippets.

@adampax
Forked from kwhinnery/app.js
Created August 30, 2011 20:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adampax/1181866 to your computer and use it in GitHub Desktop.
Save adampax/1181866 to your computer and use it in GitHub Desktop.
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');
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