Subs: Ember

// Unsubscribe (important!) this.eventBus.off('data-updated', this, this.handleUpdate);

constructor() super(...arguments); this.priceFeed.connect(); ember subs

// app/services/event-bus.js import Service from '@ember/service'; import Evented from '@ember/object/evented'; export default class EventBusService extends Service.extend(Evented) {} // Unsubscribe (important

⚠️ Use sparingly – overuse makes data flow hard to trace. | Pitfall | Fix | |---------|-----| | Forgetting to unsubscribe | Always call disconnect() or .off() in willDestroy | | Memory leaks | Check that references to components/services are cleared | | Stale data | Verify subscription updates tracked properties correctly | | Multiple subscriptions | Use a single service as the source of truth | // Unsubscribe (important!) this.eventBus.off('data-updated'

// app/components/price-display.js import Component from '@glimmer/component'; import inject as service from '@ember/service'; export default class PriceDisplayComponent extends Component @service priceFeed;

Most read articles by the same author(s)

1 2 > >>