injectSetAtom
Signature
injectSetAtom<T>(atom: Atom<T>): SetterFn<T>valdres-angular Write-only access to an atom
Returns a setter function for an atom without subscribing to changes. The component won't be checked for changes when the atom updates.
Usage
import { Component } from "@angular/core"
import { atom } from "valdres"
import { injectSetAtom } from "valdres-angular"
const countAtom = atom(0)
@Component({
selector: "app-increment",
template: `<button (click)="increment()">+</button>`,
})
export class IncrementComponent {
private setCount = injectSetAtom(countAtom)
increment = () => this.setCount(c => c + 1)
}
See also
- injectAtom — read + write signal
- injectResetAtom — reset to default value