Skip to content

Promises #86

Closed
Closed
@sagikazarmark

Description

@sagikazarmark

Implementations

Currently we have our own Promise interface, which is fine. It seems that we won't have a Promise PSR anytime soon.

However, there are already awesome promise packages:

I remember that Guzzle used to use ReactPHP's promise implementation. Maybe @mtdowling could tell us why they created their own?

Anyway: would it make sense to rely on third party promise implementations instead of ours?

Possible ways:

  • Keep the interface in the contract and use wrappers around third-party promises
  • Drop our interface and rely on a third-party directly (which would require relying on an implementation in the contract)

Convenience methods

Currently we have two convenience methods: getResponse and getException. These are what make our interface a "special" promise implementation. As the above two implementations, ours claim to be an implementation of Promises/A+ standard. Although I see the point in these methods, I think we should probably get rid of them.

Here are a few reasons:

  • If a Promise PSR ever becomes real, we would still need to extend it. In this case we couldn't just accept any kind of promises to be used.
  • The same case, if we want to use a third-party implementation now.
  • It is not part of the original standard, but as I can see, returning the value in the wait method is.

I propose removing those method. However in that case we need a "standard" way of getting the value and deciding whether it is an exception, a response, or an invalid value. Checking the type is obvious, but might led to duplicated code. Maybe we could check how Guzzle does it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions