github preactjs/signals @preact/signals-core@1.11.0

latest releases: @preact/signals-core@1.12.1, @preact/signals-preact-transform@0.1.0, @preact/signals@2.3.1...
2 months ago

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

Don't miss a new signals release

NewReleases is sending notifications on new releases.