Skip to content

Instantly share code, notes, and snippets.

@saiumesh535
Last active November 17, 2018 15:25
Show Gist options
  • Save saiumesh535/c559154ee7d42fa885e7fd13c94f0d91 to your computer and use it in GitHub Desktop.
Save saiumesh535/c559154ee7d42fa885e7fd13c94f0d91 to your computer and use it in GitHub Desktop.
Promisify Observable with callback function
import { Observable, of } from "rxjs";
export const promisify = <T>(obser: Observable<T>): Promise<T> => {
return obser.toPromise();
};
function something(func: (...args) => Promise<void>): any {
return func({cockIt: promisify});
}
function check(): Promise<void> {
return something(async ({cockIt}) => {
const lol = await cockIt(of(33));
// tslint:disable-next-line:no-console
console.log(lol);
});
}
check();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment