Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-promise-cps

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-promise-cps

Promise Proxy Object computed properties

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

ember-promise-cps

       

This Ember addon provides you with a computed property macros to aid with common problems when passing promises into components:

  1. Subsequent promises take priorty over 'old' promises
    (You're usually only ever bothered about the result from the most recent promise)
  2. Setting the result of the promise on the component when the component may since have been destroyed.

Example

{{! application.hbs }}
{{items-list items-promise=promiseForItems}}
// items-list/component.js
import { promiseObject } from 'ember-promise-cps/macros';

export default Component.extend({
  items: promiseArray('items-promise')
});
{{! items-list/template.hbs }}
{{#if items.isPending}}
  Loading items
{{else if items.isRejected}}
  Unable to display items: {{items.reason}}
{{else if items.isFulfilled}}
  {{#each items as |item|}}
    ...
  {{/each}}
{{/if}}

Available utils/macros

  • Utils
    • promiseObject({ foo: 'bar' })
    • promiseArray([ 'foo', 'bar' ])
  • Macros
    • promiseObject('myObject')
    • promiseArray('myArray')

Notes

  1. If you use helpers to resolve the promise inside your template like:
{{#if (await items)}}
  {{#each items as |item|}}
    ...
...then the downside is you don't _also_ have the ability to base more computed properties on the result of that promise in the component itself. (It's more useful to resolve the promise in the component, and let your template read the properties rather than the other way around. It also leads to simpler templates).

2. If you need something more substantial, see: http://ember-concurrency.com/

Installation

ember install ember-promise-cps

Keywords

FAQs

Package last updated on 31 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc