Skip to content

Instantly share code, notes, and snippets.

Tom Dale tomdale

Block or report user

Report or block tomdale

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tomdale
tomdale / proposal.md
Last active Oct 16, 2019
Ember Data / Ember Ajax / Ember Fetch proposal
View proposal.md

Networking in Ember

Motivation

Most client-side applications need to fetch data over the network. In the Ember.js ecosystem, many developers use a high-level abstraction, like Ember Data, that standardizes network access via an adapter pattern.

For those who want more low-level control over data fetching, it is

@tomdale
tomdale / action.js
Created Oct 4, 2019
bind vs. action decorators
View action.js
import Component, { tracked, action } from '@glimmer/component';
export default class extends Component {
@tracked count = 0;
@action increment() {
this.count++;
}
}
@tomdale
tomdale / .vsls.json
Created Jul 11, 2019
Visual Studio Live Share gitignore configuration
View .vsls.json
{
"$schema": "http://json.schemastore.org/vsls",
"gitignore":"none"
}
@tomdale
tomdale / class-template.ts
Created Jun 4, 2019
Class Template Strawman
View class-template.ts
import Component, { gbs } from '@glimmer/component';
export default class extends Component {
static template = gbs`
<h1>Hello {{this.world}}</h1>
`
}
View forwarding-blocks.md

Forwarding Named Blocks in Glimmer

Use Case

A component that "forwards" passed blocks to a child component. For example, imagine we have a component called MiniCard that accepts a named block called header. It is invoked like this:

<MiniCard>
  <:header>
    My Card
@tomdale
tomdale / survey.md
Last active Dec 22, 2018
Ember Component Lifecycle Hooks Survey
View survey.md

Component Lifecycle Hooks Survey

Most Ember developers are familiar with component lifecycle hooks, like didInsertElement, willDestroy, etc.

As we think about future APIs for Glimmer components that improve on lifecycle hooks, we want to make sure that we're providing abstractions that are simple, performant, and ergonomic, while nudging users towards good patterns and away from potential footguns.

@tomdale
tomdale / index.js
Created Dec 6, 2018
Tracked property notify API strawman
View index.js
import Timer from 'simple-timer';
import Component from '@glimmer/component';
import { } from '@glimmer/tracking';
export default class TimerComponent extends Component {
constructor() {
// Mark the timer as "untracked" (i.e., we're asserting
// that timer contains no interior tracked properties at all).
// This function gives us back the timer as well as a callback
// function to call when any interior mutation may have occurred.
@tomdale
tomdale / local-storage-array.js
Created Apr 28, 2014
Ember Array that writes every change to localStorage
View local-storage-array.js
export default Ember.ArrayProxy.extend({
localStorageKey: null,
init: function() {
var localStorageKey = this.get('localStorageKey');
if (!localStorageKey) {
throw new Error("You must specify which property name should be used to save " + this + " in localStorage by setting its localStorageKey property.");
}
View components.container-component.js
import Ember from 'ember';
export default Ember.Component.extend({
componentName: "inner-component",
actions: {
handleComponentChange() {
this.set('componentName', "second-component");
}
}
});
View bytecode-format.txt
/* Fixed Opcode */ /* Operand? */ /* Operand? */ /* Operand? */
[0bIIIIIIIILLRRRRRR, 0bAAAAAAAAAAAAAAAA, 0bAAAAAAAAAAAAAAAA, 0bAAAAAAAAAAAAAAAA]
/*
I = instruction (opcode) type
L = operand length
R = reserved
A = operand value
*/
You can’t perform that action at this time.