Skip to content

Instantly share code, notes, and snippets.

@mikemunsie
Last active February 12, 2018 20:56
Show Gist options
  • Save mikemunsie/80533b89c1b407704231bda7ff39bc88 to your computer and use it in GitHub Desktop.
Save mikemunsie/80533b89c1b407704231bda7ff39bc88 to your computer and use it in GitHub Desktop.
ember-secrets

Renaming attributes in a serializer:

export default DS.JSONAPISerializer.extend({
 attrs: { results: 'data' }
});

Customizing the key in a list '@identity', '@index', or your own:

<div>
 {{#each items key=key as |item i|}}
 {{/each}}
</div>

Use Ember Computed macro helpers to make life easier:

import { filterBy, mapBy, reduce, rejectBy } from 'ember-awesome-macros/array';
import raw from 'ember-macro-helpers/raw';
...
myKey: 'test',
prop: filterBy('conditions', raw('newDamage')), // Actually filter by string value
prop2: filterBy('conditions', 'myKey') // Filter by the value of 'myKey' which is 'test'

Ember get returns a promise, but on a nested property, you get a promise that returns a promise

groupPrices.get('driverGroup'); // returns a promise
groupPrices.get('driverGroup.drivers'); // returns a promise that returns a promise (and so forth for each nested attr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment