No tasks yet
{{/if}} } ``` ## Avoid Nested Conditionals **Bad:** ```glimmer-js {{#if @user}} {{#if @user.isPremium}} {{#if @user.hasAccess}}Unsupported media type
{{/if}} } ``` ## Loading States Pattern for async data with loading/error states: ```glimmer-js // app/components/data-display.gjs import Component from '@glimmer/component'; import { Resource } from 'ember-resources'; import { resource } from 'ember-resources'; class DataResource extends Resource { @tracked data = null; @tracked isLoading = true; @tracked error = null; modify(positional, named) { this.fetchData(named.url); } async fetchData(url) { this.isLoading = true; this.error = null; try { const response = await fetch(url); this.data = await response.json(); } catch (e) { this.error = e.message; } finally { this.isLoading = false; } } } class DataDisplay extends Component { @resource data = DataResource.from(() => ({ url: this.args.url, })); {{#if this.data.isLoading}}