Tag: “tammy nyp”

Ember Subs [exclusive] Direct

Only use subscriptions when data enters your app . 3. Subscribing to External Data (Best Practice) Step 1: Create a service // app/services/price-feed.js import Service from '@ember/service'; import tracked from '@glimmer/tracking'; import action from '@ember/object'; export default class PriceFeedService extends Service @tracked currentPrice = null; @tracked isConnected = false;

#if this.priceFeed.isConnected Current price: this.priceFeed.currentPrice else Connecting... /if ✅ No manual observers – just tracked properties and lifecycle hooks. 4. Subscriptions with Ember Data (Live Queries) If your backend pushes changes via WebSockets, update the store directly: ember subs

// Unsubscribe (important!) this.eventBus.off('data-updated', this, this.handleUpdate); Only use subscriptions when data enters your app

Navigation