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

Change Group#promise? to check respond_to?(:then) #27

Open
singpolyma opened this issue Mar 16, 2017 · 2 comments
Open

Change Group#promise? to check respond_to?(:then) #27

singpolyma opened this issue Mar 16, 2017 · 2 comments

Comments

@singpolyma
Copy link

That way we can use things which do not inherit from Promise but which obey the interface with helpers like all

@dylanahsmith
Copy link
Collaborator

Promise.all isn't just implemented by calling then on the passed objects. It is kind of possible to implement Promise.all only using then as the interface for a promise, but then sync couldn't be used on the returned promise. Another behaviour change that would be needed would be that the returned promise wouldn't be rejected as soon as any input promise is rejected.

What is the actual use case? Are you trying to integrate promise.rb with some other library that implements promises? Since there are inconsistencies in just the then method between libraries.

E.g. concurrent-ruby uses the signature def then(rescuer = nil, executor = @executor, &block) compared to promise.rb that uses def then(on_fulfill = nil, on_reject = nil, &block)

Why can't you just use Promise or a class deriving from Promise?

@singpolyma
Copy link
Author

I thought when reading the source that all only used then, but I guess I missed something :)

I'm integrating promise.rb with EventMachine and trying to be as seamless as possible, so it would be nice if all could take an array of mixed promises and deferrables (I've monkeypatched then onto deferrable -- it converts into a promise and then uses Promise#then, so totally compatible)

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