Last active
November 17, 2018 15:25
-
-
Save saiumesh535/c559154ee7d42fa885e7fd13c94f0d91 to your computer and use it in GitHub Desktop.
Promisify Observable with callback function
This file contains hidden or 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
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