Skip to content

♻️ Invert reducer ↔ delimiter control#1164

Merged
cowboyd merged 1 commit into
v4from
cl/invert-reducer
May 14, 2026
Merged

♻️ Invert reducer ↔ delimiter control#1164
cowboyd merged 1 commit into
v4from
cl/invert-reducer

Conversation

@cowboyd
Copy link
Copy Markdown
Member

@cowboyd cowboyd commented May 7, 2026

Motivation

Issues #1153, #1154, and #1159 share a single root cause: cancellation
in v4 is one-shot.

The proposed fix is to have the co-routine, after cancellation, continually return, and return, and return with each yield, and then protect "critical" sections with a shield that makes normal execution for secments of the effect stream.

This PR is an attempt to enable these refactors by allowing the conetxt control exactly how the co-routine is advanced at every stem.

Approach

Invert control from the co-routine to the delimiter.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

Open in StackBlitz

npm i https://pkg.pr.new/effection@1164

commit: a03cbb0

In order to implement critical sections that cannot be interrupted and
that are also able to implement sticky return, we need to make the
behavior of the reducer more context sensitive.

This drops the whole validation behavior and instead completely
inverts control over iteration to the delimiter from the reducer. Now,
the reducer becomes a pure iterator-stepping engine. The delimiter can
tell it to use "next", "return", "throw" to tell it how to advance the
iterator, or it can even tell it "drop" to ignore the dequeued item
entirely.
Copy link
Copy Markdown
Member

@taras taras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rubber

@cowboyd cowboyd merged commit 3e7afa4 into v4 May 14, 2026
17 checks passed
@cowboyd cowboyd deleted the cl/invert-reducer branch May 14, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants