Skip to content

Instantly share code, notes, and snippets.

@vishwanatharondekar
Last active February 18, 2017 11:09
Show Gist options
  • Save vishwanatharondekar/287663d29536324baa0128de7756a042 to your computer and use it in GitHub Desktop.
Save vishwanatharondekar/287663d29536324baa0128de7756a042 to your computer and use it in GitHub Desktop.
export const mobileRenderable = function (target, name, descriptor) {
const originalRender = target.prototype.render
let mobileRender = target.prototype.renderMobile
//Device identification
let device = deviceIdentification().formFactor || 'desktop'
let functionToCall = null
if (device === 'mobile') {
functionToCall = mobileRender
} else {
functionToCall = originalRender
}
//Overwrite render with render method to call on basis of form factor
target.prototype.render = functionToCall
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment