HTTPRequest/pkg::Install: do not replace callbacks.

Keep a list of callbacks to allow registering multiple callbacks
to the same event. This is consistent with eg. jQuery.Deferred
and is needed for example to open multiple dialogs showing the
progress of installing a package at the same time.
This commit is contained in:
Thomas Geymayer
2014-06-30 18:22:24 +02:00
parent dc4644bf3a
commit 0b60643053
8 changed files with 204 additions and 36 deletions
+6 -9
View File
@@ -39,7 +39,7 @@ Request* Request::done(const Callback& cb)
if( _ready_state == DONE )
cb(this);
else
_cb_done = cb;
_cb_done.push_back(cb);
return this;
}
@@ -50,7 +50,7 @@ Request* Request::fail(const Callback& cb)
if( _ready_state == FAILED )
cb(this);
else
_cb_fail = cb;
_cb_fail.push_back(cb);
return this;
}
@@ -61,7 +61,7 @@ Request* Request::always(const Callback& cb)
if( isComplete() )
cb(this);
else
_cb_always = cb;
_cb_always.push_back(cb);
return this;
}
@@ -321,22 +321,19 @@ void Request::setReadyState(ReadyState state)
onDone();
onAlways();
if( _cb_done )
_cb_done(this);
_cb_done(this);
}
else if( state == FAILED )
{
onFail();
onAlways();
if( _cb_fail )
_cb_fail(this);
_cb_fail(this);
}
else
return;
if( _cb_always )
_cb_always(this);
_cb_always(this);
}
//------------------------------------------------------------------------------