I've been working with Angular using TypeScript and I'm attempting to return a promise from an observable. What is the correct way to accomplish this?
So far, I have tried the following:
of(EMPTY).toPromise() // error: Promise<Observable<never>>' is not assignable to type Promise<void>
of(null).toPromise() // no error but not sure if it's the right approach
of().toPromise // error: Promise<Observable<unknown>>' is not assignable to type Promise<void>
Update:
// This is the interface that defines it
export interface CustomStoreOptions extends StoreOptions<CustomStore> {
/** Specifies a custom implementation of the remove(key) method. */
remove?: ((key: any | string | number) => Promise<void> | JQueryPromise<void>);
}
It is invoked like this:
let store = new CustomStore({
remove: key => {
// return ...
}
});