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

Rename IPromise.Transform to IPromise.Then #4

Closed
cgarciae opened this issue Sep 4, 2015 · 3 comments
Closed

Rename IPromise.Transform to IPromise.Then #4

cgarciae opened this issue Sep 4, 2015 · 3 comments

Comments

@cgarciae
Copy link

cgarciae commented Sep 4, 2015

Its not ambiguous and you only have to remember 1 method. I use Dart which has a standard Futures library and I find it a lot easier.

@ashleydavis
Copy link
Contributor

I wish that were possible. I haven't found a way to have Transform be Then and still compile.

If you can find a way to do this please fork the repo, make the change and submit a pull request.

I'd be very keen to have it work the way you suggest.

@cgarciae
Copy link
Author

cgarciae commented Sep 7, 2015

Hi @ashleydavis,

I think #1 made possible refactoring Transform to Then. I did it on my version project and it worked with no compiler errors out of the box. I'll try to open the git repo by itself and refactor + pass some changes I made:

  1. I added a new public Promise<PromisedT> (PromisedT value) constructor to create a resolved promise, it seemed important because this is the monadic "Return" function.
  2. Changed the internals of Transform (now called Then) to just "fallback" to the "bind" Then using the new constructor like this:
        public IPromise<ConvertedT> Then<ConvertedT>(Func<PromisedT, ConvertedT> f)
        {
            //Argument.NotNull(() => transform);
            return Then((PromisedT t) => (IPromise<ConvertedT>)new Promise<ConvertedT>(f(t)));
        }

I have experience with Futures/Promises since I made my own Futures library for the project, as far as I saw it worked perfectly but I decided to use your library once #1 was solved.

@ashleydavis
Copy link
Contributor

I'll be really happy if you can get Transform changed to Then ;)

Please submit a PR when you are ready to get your change in.

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

2 participants