-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
Switch matrix-js-sdk to bluebird #490
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbkr
reviewed
Jul 12, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise lgtm
spec/npm-debug.log
Outdated
23 error Or if that isn't available, you can get their info via: | ||
23 error npm owner ls matrix-js-sdk | ||
23 error There is likely additional logging output above. | ||
24 verbose exit [ 1, true ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably didn't mean to commit this
oh, and apart from the conflict |
``` find src spec -name '*.js' | xargs perl -i -pe 'if (/require\(.q.\)/) { $_ = "import Promise from '\''bluebird'\'';\n"; }' find src spec -name '*.js' | xargs perl -i -pe 'if (/import q/) { $_ = "import Promise from '\''bluebird'\'';\n"; }' ```
``` find src spec -name '*.js' | xargs perl -i -pe 's/\bq(\([^(]*\))/Promise.resolve$1/' ```
``` find src spec -name '*.js' | xargs perl -i -pe 's/q\.Promise/Promise/' ```
``` find src spec -name '*.js' | xargs perl -i -pe 's/q\.(all|defer|reject|delay|try)\(/Promise.$1(/' ```
Bluebird promises don't have an `inspect()` method, but do have an `isFulfilled()` and a `value()` method, so use them instead.
you're supposed to call Promise() as a constructor rather than a static function.
This was referenced Jul 12, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The reasons for this are twofold.
Firstly, the use of
q
has long been a thorn in our side. Reasons to prefer bluebird include:done
.Secondly, and more pressingly, I am starting to introduce (on a different branch) use of
async
andawait
, which is much nicer to work with than managing the promises directly, but introduces the problem that (by default)async
functions return nativePromises
, whilst historical parts of the js-sdk returnq
promises, meaning that one is never sure whether or not to calldone
. With this change, everything will return a bluebirdPromise
, which means that you can calldone
(so backwards compatibility is maintained), but don't have to.It's worth noting that, having done
import Promise from 'bluebird'
, any shims generated forasync
functions by Babel's transform-async-to-generator end up as bluebird Promises.