# @publish

Write-only binding: assigning to the property publishes to the `DataProviderKey` path. No read subscription (inverse of [@subscribe](#docs/_decorators/subscribe.md/subscribe)).

Similar to the “reflect” half of [@bind](#docs/_decorators/bind.md/bind) without listening to the publisher.

## Import

<sonic-code language="typescript">
  <template>
import { publish } from "@supersoniks/concorde/decorators";
import { sub } from "@supersoniks/concorde/directives";
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
  </template>
</sonic-code>

## Example

<sonic-code language="typescript">
  <template>
type PublishDemoData = { email: string; message: string };
const publishDemoKey = new DataProviderKey<PublishDemoData>("publishDemo");
//
@customElement("demo-publish")
export class DemoPublish extends LitElement {
  @publish(publishDemoKey.email)
  @state()
  email = "";
  //
  @publish(publishDemoKey.message)
  @state()
  message = "";
  //
  render() {
    return html`
      <sonic-input
        .value=${this.email}
        @input=${(e) => (this.email = (e.target as HTMLInputElement).value)}
        label="Email"
      ></sonic-input>
      <p>${sub("publishDemo.email")}</p>
    `;
  }
}
  </template>
</sonic-code>

<sonic-code>
  <template>
    <demo-publish></demo-publish>
  </template>
</sonic-code>

Dynamic paths use the same placeholder rules as `@bind` / `@subscribe`.
