Skip to content

Instantly share code, notes, and snippets.

@vitalets
Created December 18, 2019 15:12
Show Gist options
  • Save vitalets/a5b7dab8ca4b1912f7b3658f14d41017 to your computer and use it in GitHub Desktop.
Save vitalets/a5b7dab8ca4b1912f7b3658f14d41017 to your computer and use it in GitHub Desktop.
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