Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcusramberg/c445646a81b73fcee6e77429bd12bfea to your computer and use it in GitHub Desktop.
Save marcusramberg/c445646a81b73fcee6e77429bd12bfea to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojo/Promise.pm b/lib/Mojo/Promise.pm
index 19fdd8617..a84ff6006 100644
--- a/lib/Mojo/Promise.pm
+++ b/lib/Mojo/Promise.pm
@@ -2,6 +2,7 @@ package Mojo::Promise;
use Mojo::Base -base;
use Mojo::IOLoop;
+use Mojo::Util 'deprecated';
use Scalar::Util 'blessed';
has ioloop => sub { Mojo::IOLoop->singleton }, weak => 1;
@@ -67,7 +68,9 @@ sub map {
}
sub new {
- return shift->SUPER::new(@_) if @_ > 2 or ref($_[1]) eq 'HASH';
+ deprecated('->new with attributes is DEPRECATED in favor of ->new->ioloop(..)')
+ && return shift->SUPER::new(@_)
+ if @_ > 2 or ref($_[1]) eq 'HASH';
my $self = shift->SUPER::new;
shift->(sub { $self->resolve(@_) }, sub { $self->reject(@_) }) if @_;
return $self;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment