• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
postpostscript

postpostscript

interruptibleChain

Public
Like
interruptibleChain
Home
Code
2
README.md
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
1/7/2025
Viewing readonly version of main branch: v2
View latest version
README.md

interruptibleChain: simple interface for pausing and resuming execution chains

⚠️ Moved to GitHub ⚠️

Create val
import { $chain } from "https://esm.town/v/postpostscript/interruptibleChain"; const multiply = $chain() .then(() => 1) .then((x) => x + 3) .then(async (x) => { await new Promise((resolve) => setTimeout(resolve, 1000)); return x * 2; }); const handle = multiply.init(); console.log(await handle.untilDone()); // { done: true, value: 8, handle: InterruptibleChainHandle { ... } } const handle2 = multiply.init({ index: 2, value: 4, }); await handle2.advance(); console.log(handle2.done, handle2.state); // true { index: 3, value: 8 } /**** Interrupts ****/ const handle3 = $chain().then(() => { throw new Error("failed"); }).init(); await handle3.advance(); console.log(handle3.done, handle3.interrupt); // false Interrupt { reason: Error: failed, chain: InterruptibleChain { index: 0 } } console.log(await handle3.untilDone()); // { done: false, interrupt: Interrupt { ... }, handle: InterruptibleChainHandle { ... } } const handle4 = $chain().then((_, interrupt) => { return interrupt("call me later"); }).init(); await handle4.advance() console.log(handle4.done, handle4.interrupt); // false Interrupt { reason: "call me later", chain: InterruptibleChain { index: 0 } }

Migrated from folder: Archive/interruptibleChain

FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.