Skip to content
Compare
Choose a tag to compare
@github-actions github-actions released this 29 Jun 06:37
· 3 commits to main since this release
12cef4c

Minor Changes

  • #706 4045d2d Thanks @marvinhagemeister! - feat: support disposing effect() with resource management

    This allows effect()'s to be disposed with the new using keyword from the explicit resource management proposal.

    Whenever an effect goes out of scope the Symbol.dispose function is called automatically.

    const count = signal(0);
    
    function doSomething() {
    	// The `using` keyword calls dispose at the end of
    	// this function scope
    	using _ = effect(() => {
    		console.log(count.value);
    		return () => console.log("disposed");
    	});
    
    	console.log("hey");
    }
    
    doSomething();
    // Logs:
    //  0
    //  hey
    //  disposed