Skip to content

angular

import {
  useStore
} from "exome/angular";

function useStore

Creates Angular signal and subscribes to store instance update events and trigger updates to component accordingly.

function useStore<T extends Exome, R = T>(
  store: T,
  selector?: (state: T) => R,
): Signal<R>;
example.ts
import { useStore } from "exome/angular"
import { counterStore } from "./counter.store.ts"
 
@Component({
  selector: 'my-app',
  template: `
    <button (click)="increment()">
      {{count}}
    </button>
  `,
})
export class App {
  public count = useStore(counterStore, (s) => s.count)
 
  public increment() {
    counterStore.increment()
  }
}