Skip to content

Instantly share code, notes, and snippets.

@Sinled
Last active October 4, 2016 19:16
Show Gist options
  • Save Sinled/bb7e35144543bb41758cdaa08eab9b00 to your computer and use it in GitHub Desktop.
Save Sinled/bb7e35144543bb41758cdaa08eab9b00 to your computer and use it in GitHub Desktop.
silent fail
import DS from 'ember-data';
export default DS.Adapter.extend({
// Mock response
queryRecord: function(store, type, query) {
return new Ember.RSVP.Promise(function(resolve, reject) {
console.log('fetching data');
resolve({ some: 'some string', id: 1 });
});
}
});
import Ember from 'ember';
export default Ember.Component.extend({
list: Ember.computed(function() {
throw new Error('blabla');
return [1, 2, 3];
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Model from "ember-data/model";
import attr from "ember-data/attr";
import { belongsTo, hasMany } from "ember-data/relationships";
export default Model.extend({
some: attr('string'),
});
import Ember from 'ember';
export default Ember.Route.extend({
glossary: Ember.inject.service(),
beforeModel(transition) {
this._super(...arguments);
// Setup glossary service before application start
const appInitData = Ember.RSVP.all([
this.get('glossary').setup(this.store),
]);
appInitData.catch((error) => {
console.error(error);
});
return appInitData;
},
});
import Ember from 'ember';
const { Service, inject, RSVP } = Ember;
export default Service.extend({
data: [],
setup(store) {
const self = this;
return new RSVP.Promise(function(resolve, reject) {
store.queryRecord('glossary', {})
.then((responseData) => {
self.set('data', responseData);
resolve();
});
});
},
});
<h1>Welcome to {{appName}}</h1>
<br>
<hr>
{{my-component someAction=(action 'someControllerAction') }}
<h1>Component rendered</h1>
{{#each list as |item|}}
{{item}} <hr>
{{/each}}
{
"version": "0.10.5",
"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.7.3",
"ember-data": "2.8.0",
"ember-template-compiler": "2.7.3",
"ember-testing": "2.7.3"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment