Skip to content

Instantly share code, notes, and snippets.

@vitalets vitalets/webostv.js
Created Dec 18, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.