Last active
February 18, 2017 11:09
-
-
Save vishwanatharondekar/287663d29536324baa0128de7756a042 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
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