-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove Promise.done() since onunhandledrejection does it authomatically
- Loading branch information
1 parent
a359d8c
commit 390b34f
Showing
5 changed files
with
26 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Signum.Upgrade.Upgrades; | ||
|
||
class Upgrade_20220805_DoneIsDone : CodeUpgradeBase | ||
{ | ||
public override string Description => "Remove .done() (rejectionhandled does it)"; | ||
|
||
public static Regex DoneRegex = new Regex(@"\s*\.done\(\)"); | ||
public override void Execute(UpgradeContext uctx) | ||
{ | ||
uctx.ForeachCodeFile(@"*.tsx, *.ts", file => | ||
{ | ||
file.Replace(DoneRegex, ""); | ||
}); | ||
} | ||
} |
390b34f
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.
Remove Promise.done()
This commit removes the method
done
previously injected into thePromise.prototype
that was responsible for throwing the rejection error into the event loop to, ultimately, show an error message to the user.This functionality can now be automatically archived using the unhandledrejection event that is available in every browser but IE
This also means that
async
/await
can not be used more aggresively. For example avoid
returning method like this:Was not worth to write it with
async
/await
because of thedone
method and the radical transpilation required for IE.Now all this is gone so feel free to write this instead:
How to Upgrade
The Signum.Upgrade
Upgrade_20220805_DoneIsDone
should remove al yourdone()
calls, like this: e727d00If you want to replace
.then()
forasync
/await
you will need to do it manually in a case-by-case basis.Emjoy