Concepts
Completion guard after disposal
Prevent stale completion from updating a disposed owner, independently of whether the dependency honors cancellation.
Formal Syntax & Structure
javascript syntaxjavascript
if (active && generation === requestGeneration) publish(result)Working Example
Example Snippetjavascript
(async () => {let active=true,publish=[];let resolve;const pending=new Promise(r=>resolve=r);const done=pending.then(x=>{if(active)publish.push(x);});active=false;resolve("late");await done;console.log(JSON.stringify(publish));})()