Skip to content

Instantly share code, notes, and snippets.

@jpadilla
Created May 3, 2016 20:37
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 jpadilla/30a6eedf3516fb13f9abbee325404171 to your computer and use it in GitHub Desktop.
Save jpadilla/30a6eedf3516fb13f9abbee325404171 to your computer and use it in GitHub Desktop.
promise-proxy-mixin-example
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
isBooked: Ember.computed(function() {
var ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin);
return ObjectPromiseProxy.create({
promise: $.getJSON('https://httpbin.org/get')
});
})
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
<p>isPending: {{if isBooked.isPending "pending" "-"}}</p>
<p>isSettled: {{if isBooked.isSettled "settled" "-"}}</p>
<p>isRejected: {{if isBooked.isRejected "rejected" "-"}}</p>
<p>isFulfilled: {{if isBooked.isFulfilled isBooked.origin "-"}}</p>
{
"version": "0.8.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment