injectValue

Signature
injectValue<T>(state: Atom<T> | Selector<T>): Signal<T>

valdres-angular Read-only subscription to state

Returns a read-only Angular Signal that tracks an atom or selector value. The signal updates whenever the underlying state changes.

Usage

import { Component } from "@angular/core"
import { atom, selector } from "valdres"
import { injectValue } from "valdres-angular"

const nameAtom = atom("Valdres")
const greetingSelector = selector(get => `Hello, ${get(nameAtom)}!`)

@Component({
    selector: "app-greeting",
    template: `<h1>{{ greeting() }}</h1>`,
})
export class GreetingComponent {
    greeting = injectValue(greetingSelector)
}

See also