Skip to content

Commit

Permalink
[fix] wait() filter didn't buffer more than one events when using a P…
Browse files Browse the repository at this point in the history
…romise
  • Loading branch information
pajama-coder committed Jun 5, 2024
1 parent 9b0601d commit 221edef
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/filters/wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ void Wait::process(Event *evt) {
if (m_fulfilled) {
output(evt);

} else if (!m_promise_callback) {
pjs::Value ret;
if (!callback(m_condition, 0, nullptr, ret)) return;
if (ret.is_promise()) {
auto cb = PromiseCallback::make(this);
ret.as<pjs::Promise>()->then(nullptr, cb->resolved(), cb->rejected());
m_promise_callback = cb;
} else if (ret.to_boolean()) {
fulfill();
Filter::output(evt);
} else {
if (!m_promise_callback) {
pjs::Value ret;
if (!callback(m_condition, 0, nullptr, ret)) return;
if (ret.is_promise()) {
auto cb = PromiseCallback::make(this);
ret.as<pjs::Promise>()->then(nullptr, cb->resolved(), cb->rejected());
m_promise_callback = cb;
} else if (ret.to_boolean()) {
fulfill();
Filter::output(evt);
}
}

if (!m_fulfilled) {
Expand Down

0 comments on commit 221edef

Please sign in to comment.