Concorde documentation · same URL (interactive) · llms.txt

Concorde decorator — @autoSubscribe. Legacy decorator that re-runs a method whenever one of the store values it reads is assigned. For new code, prefer @subscribe with a DataProviderKey: dependencies are explicit and typed. Doc ID: docs/decorators/auto-subscribe. Keywords: Concorde, supersoniks, docs/decorators/auto-subscribe, auto-subscribe, @autoSubscribe, decorator, autoSubscribe, DataProviderKey, connectedCallback, @state(), requestUpdate(), queueMicrotask, disconnectedCallback, @autoSubscribe(). URL: https://concorde.supersoniks.org/docs/decorators/auto-subscribe.

@autoSubscribe

Legacy decorator that re-runs a method whenever one of the store values it reads is assigned. For new code, prefer @subscribe with a DataProviderKey: dependencies are explicit and typed.

Import

import { autoSubscribe } from "@supersoniks/concorde/decorators";
import { get } from "@supersoniks/concorde/utils";

@autoSubscribe()
updateDisplay() {
  this.total = get(passengersKey) + get(crewKey);
}

Tracked reads

The method runs once after connectedCallback. Every store value read during that run becomes a dependency; assigning any of them runs the method again. Write the result to a @state() property (or call requestUpdate()) so the component re-renders.

<docs-demo-sources for="demo-auto-subscribe"></docs-demo-sources>
    <demo-auto-subscribe></demo-auto-subscribe>

Notes

API reference

Argument Type Description
none @autoSubscribe() takes no argument; apply it to a method of a custom element