Skip to content

Instantly share code, notes, and snippets.

@taras
Last active June 19, 2016 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save taras/d17759f1c7af3d3f230ed6381d0d4c3c to your computer and use it in GitHub Desktop.
Save taras/d17759f1c7af3d3f230ed6381d0d4c3c to your computer and use it in GitHub Desktop.
{{#with (ajax-get '/products') as |request|}}
{{#with (async request request.fetch) as |result|}}
{{#if result.isPending}}
<progress value={{request.progress}} max=100></progress>
{{else}}
<button onclick={{action request.reset}}>Reload</button>
{{/if}}
{{#loading-overlay result.isPending}}
{{#with (list result) as |items|}}
{{#each items as |product}}
{{product.title}}
<button onclick={{ajax-delete 'products/:id'
data=(hash id=item.id)
on-success=(action products.remove product)
on-error=(action notifications.error 'Could not delete item')
}}>Delete</button>
{{/each}}
{{/with}}
{{/loading-overlay}}
{{/with}}
{{/with}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment