AUR0818

Error Message

AUR0818: "& signal" invalid usage. At least one signal name must be passed to the signal behavior, e.g. "expr & signal:'my-signal'"

Description

This error occurs when the & signal binding behavior is used in a binding expression without providing any signal names as arguments. The purpose of the signal behavior is to listen for specific named signals, so it requires at least one signal name to function correctly.

Cause

The sole cause of this error is using the signal binding behavior without specifying which signal(s) it should listen for.

Examples of incorrect usage:

  • ${myValue & signal}

  • value.bind="myProp & signal"

Solution

Provide one or more signal names as string arguments to the & signal binding behavior. Signal names are separated by colons (:).

Examples of correct usage:

  • ${myValue & signal:'my-signal-name'}

  • value.bind="myProp & signal:'signal-a':'signal-b'"

Example

<!-- Assume myData should update when 'data-updated' or 'user-changed' signals occur -->

<!-- Incorrect: No signal names provided -->
<p>${myData & signal}</p>

<!-- Correct: Provide one signal name -->
<p>${myData & signal:'data-updated'}</p>

<!-- Correct: Provide multiple signal names -->
<p>${myData & signal:'data-updated':'user-changed'}</p>
// View Model Example
import { customElement, ISignaler } from 'aurelia';

@customElement({ /* ... */ })
export class MyComponent {
  myData = 'Initial Data';
  userInfo = 'User A';

  constructor(@ISignaler private signaler: ISignaler) {}

  refreshData() {
    this.myData = `Refreshed at ${new Date().toLocaleTimeString()}`;
    this.signaler.dispatchSignal('data-updated');
  }

  changeUser() {
    this.userInfo = `User ${Math.random() > 0.5 ? 'B' : 'C'}`;
    // Assuming myData calculation depends on userInfo indirectly,
    // we might signal both. Or maybe a different binding listens for 'user-changed'.
    this.signaler.dispatchSignal('user-changed');
    this.signaler.dispatchSignal('data-updated'); // Or re-signal data if it depends on user
  }
}

Debugging Tips

  • Locate the binding expression using & signal in your template.

  • Ensure that you have added at least one colon-separated string literal after & signal representing the name(s) of the signal(s) to listen for.

  • Verify that the signal names are spelled correctly and match the names used when dispatching signals via ISignaler.dispatchSignal().

Last updated

Was this helpful?