Skip to content

Instantly share code, notes, and snippets.

@tomdale
tomdale / gist:1856842
Created February 18, 2012 01:54
Ember documentation TODO

Documentation

TODO

  • API docs
  • How to bootstrap a project
  • Application structure (M/V/C layers and what they're for)
  • Getting started with Ember and Rails
  • Built-in controls
  • How events are handled and bubbled
@tomdale
tomdale / gist:2481356
Created April 24, 2012 16:44
One CoffeeScript ambiguity
App.messageController = Ember.Object.create
message: "Hello, world!"
# Compiles to:
# App.messageController = Ember.Object.create({
# message: "Hello, world!"
# });
# Okay, let's refactor it and delete the message property:
@tomdale
tomdale / gist:2494968
Created April 26, 2012 01:10
Ember.js View Context Change

View Context Changes

The rules for how Ember.js evaluates Handlebars templates have recently changed, and you may need to update your application's templates to ensure they continue working..

Template Contexts

Remember that a template is always evaluated against a context object. When you render a template, values are looked up from that object. For example:

Hello, {{firstName}} {{lastName}}!
@tomdale
tomdale / gist:3981133
Last active November 26, 2019 21:19
Ember.js Router API v2

WARNING

This gist is outdated! For the most up-to-date information, please see http://emberjs.com/guides/routing/!

It All Starts With Templates

An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars.

<header>
@tomdale
tomdale / gist:4004913
Created November 2, 2012 23:10
Per-Type Adapters Proposal

Per-Type Adapter Hooks

Requirements

Many existing JSON APIs are not consistent between types. As JSON endpoints grew organically and were built by different engineers at different times, the style in which records are represented can vary wildly.

Historically, we have asked adapter authors to rely on the fact that the type of record is provided to all adapter hooks (either by passing a type argument, or by passing a record

@tomdale
tomdale / gist:4242136
Created December 8, 2012 21:52
{{#each}} docs

Displaying a List of Items

If you need to enumerate over a list of objects, use Handlebar's {{#each}} helper:

<ul>
  {{#each people}}
    <li>Hello, {{name}}!</li>
  {{/each}}
</ul>
@tomdale
tomdale / gist:4263171
Created December 11, 2012 23:05
Ember Data Read-Only API Proposal

Read-Only

An important feature for Ember Data is providing helpful error messages when your application tries to do something that is forbidden by the data model.

To that end, we would like for the data model to be able to mark certain records, attributes, and relationships as read-only. This ensures that we can provide errors immediately, and not have to wait for a return trip from the adapter.

This also means that the adapter does not need to handle the case where an application developer inadvertently makes changes to a record that it does not conceptually make sense to modify on the client.

Requirements

//our app
var HelloEmber = Ember.Application.create({});
//our model
HelloEmber.Greeting = Ember.Object.extend();
HelloEmber.Greeting.reopenClass({
get : function(){
return {greeting : "Good Morning Starshine!", happyThought : "The Earth Says Hello!"}
}
});
@tomdale
tomdale / merge-handling.md
Created May 23, 2013 20:49
Ember Data Merge Handling

Ember Data Merge Handling

Internally, Ember Data models use a state machine to represent their lifecycle. One of the limitations of the current implementation is that records cannot be modified:

  • By the client application if the record is in-flight, or
  • By the server (via an out-of-band load()) if the record has pending changes on the client.
@tomdale
tomdale / with-comments.js
Last active December 21, 2015 03:29
Notional API for new Ember Data adapter
App.Adapter = DS.Adapter.extend({
/*
Called when the store needs the data payload for a particular record. It
gets the type and ID and should return a promise that resolves to a JSON
payload that contains the record.
For example, this might be called like this:
findRecord(App.Person, "1")