Skip to content

Instantly share code, notes, and snippets.

@machty
machty / controllers.application.js
Last active December 17, 2018 19:37
New Twiddle
import Ember from 'ember';
let guid = () => (Math.random().toString(36) + '00000000000000000').slice(2, 14)
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
vol: Ember.computed(function() {
return guid();
}).volatile(),
actions: {
@machty
machty / controllers.application.js
Last active October 28, 2018 09:36
New Twiddle
import Ember from 'ember';
import { lifespan, subscription } from "../subscription";
import { bind } from '@ember/runloop';
import { task, timeout } from 'ember-concurrency';
export default Ember.Controller.extend({
chatRooms:[ "EmberChat", "ReactChat", "VueChat", "AngularChat"],
chatRoom: null,
// chatRoomName: null,
@machty
machty / controllers.application.js
Last active October 28, 2018 00:22
New Twiddle
import Ember from 'ember';
import { subscription } from "../subscription";
import { bind } from '@ember/runloop';
import { task, timeout } from 'ember-concurrency';
export default Ember.Controller.extend({
chatRooms:[ "EmberChat", "ReactChat", "VueChat", "AngularChat"],
chatRoomName: null,
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
bar: "bar_initial",
foo: Ember.computed('bar', {
set(key, value) {
return `setter(${value})`;
@machty
machty / journal.md
Created June 18, 2018 15:22
ember-testing journal

Ember Testing Journal

We've been driving all of our Ember tests with end-to-end Capybara tests running from our Rails server for some time. There are many upsides to this approach, but Capybara tests are generally slow and brittle, so we'd likely to start investing in client-side only Ember tests that don't actually hit the server at all.

Given that I don't have a lot of experience with Ember tests, I wanted to keep a journal of first impressions and snags I encountered along the way, so that perhaps this information will be useful for documentation maintainers or whomever.

Figuring out how to stub a service in an acceptance test

Screencast of me talking through my through process

@machty
machty / some-route.js
Last active June 17, 2018 14:02
I have a user-activity service that exposes some observables that monitor the user clicking/tapping around and expose some convenience methods for generating new observables, which allows for the flexibility of consumers specifying different activity times. Refactoring this to use tasks vs observables points out a few awkward cases that could be…
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
const DEFAULT_INACTIVITY_TIMEOUT_MS = 10 * 60 * 1000
export default Route.extend({
session: service(),
userActivity: service(),
notifications: service(),
logoutTimeoutSubscription: null,
activate() {
import Ember from 'ember';
function * myGen() {
yield 1;
yield 2;
yield 3;
}
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
import Ember from 'ember';
import { task, timeout, waitForProperty } from 'ember-concurrency';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
lol: 'init',
foo: task(function * () {
this.set('lol', 1);
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});