Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add fromPromise to the API documentation #10

Open
christiangelone opened this issue Dec 16, 2018 · 2 comments
Open

docs: Add fromPromise to the API documentation #10

christiangelone opened this issue Dec 16, 2018 · 2 comments

Comments

@christiangelone
Copy link

christiangelone commented Dec 16, 2018

  • It would be cool a transformation from promise to task

something like

const task: Task<ValueType, ErrorType> = Task.fromPromise<ValueType, ErrorType>(promise);
@gillchristian
Copy link

gillchristian commented Dec 17, 2018

There's fromPromise already 😅

import { Task } from './task';
declare module './task' {
// tslint:disable-next-line:interface-name
namespace Task {
function fromPromise<TResult, EResult = any> (promise: Promise<TResult>): Task<TResult, EResult>;
}
}
Task.fromPromise = function <TResult, EResult = any> (promise: Promise<TResult>): Task<TResult, EResult> {
return new Task((outerResolve, outerReject) => {
promise.then(outerResolve, err => outerReject(err));
});
};

@hrajchert
Copy link
Contributor

I'll leave it open and change its name to add fromPromise to the API documentation

@hrajchert hrajchert changed the title Promise -> Task docs: Add fromPromise to the API documentation Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants