Created
December 18, 2019 15:12
-
-
Save vitalets/a5b7dab8ca4b1912f7b3658f14d41017 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 function promisifyRequest(fn) { | |
return params => { | |
return new promise(r => { | |
rthrh | |
}) | |
}; | |
} | |
export const createWebosAsPromised = webos => { | |
const webosPromised = Object.create(webos); | |
webosPromised.deviceInfo = () => new Promise(resolve => webos.getDeviceInfo(resolve)); | |
webosPromised.fetchAppInfo = path => new Promise(resolve => webos.fetchAppInfo(resolve, path)); | |
webosPromised.service.request = uri => { | |
const fn = webos.service.request.bind(webos.service, uri); | |
return promisifyRequest(fn); | |
}; | |
}; | |
export const createWebosDevAsPromised = webosDev => { | |
const webosDevPromised = Object.create(webosDev); | |
webosPromised.deviceInfo = () => new Promise(resolve => webos.getDeviceInfo(resolve)); | |
webosPromised.fetchAppInfo = path => new Promise(resolve => webos.fetchAppInfo(resolve, path)); | |
webosPromised.service.request = uri => { | |
const fn = webos.service.request.bind(webos.service, uri); | |
return promisifyRequest(fn); | |
}; | |
}; | |
webosDevPromised.drmAgent = type => { | |
const drmAgent = webostvDev.drmAgent(type); | |
const drmAgentPromised = Object.create(drmAgent); | |
drmAgentPromised.load = promisifyRequest(drmAgent.load); | |
drmAgentPromised.unload = promisifyRequest(drmAgent.unload); | |
drmAgentPromised.getRightsError = promisifyRequest(drmAgent.getRightsError); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment