Skip to content

Instantly share code, notes, and snippets.

View alexlafroscia's full-sized avatar
👋
Looking for work! Need experience with Svelte or Ember.js? Get in touch!

Alex LaFroscia alexlafroscia

👋
Looking for work! Need experience with Svelte or Ember.js? Get in touch!
View GitHub Profile
@alexlafroscia
alexlafroscia / components.my-component.js
Created November 4, 2017 19:19
Ember 2.16 assert errors
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
throw new Error('this is an error');
}
});
@alexlafroscia
alexlafroscia / components.my-scale.js
Created August 20, 2017 18:52
Yielding an Action
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
'update-value'(value) {
this.set('value', value);
}
}
});
@alexlafroscia
alexlafroscia / blog-comment.component.js
Last active September 2, 2017 13:48
Presentation & Container Components in Ember
import Ember from 'ember';
const BlogCommentComponent = Ember.Component.extend({
});
BlogCommentComponent.reopenClass({
positionalParams: ['comment']
});
export default BlogCommentComponent;
@alexlafroscia
alexlafroscia / child-component.template.hbs
Last active May 12, 2017 00:42
Passing component through HBS
This is the child component!
import Ember from 'ember';
import connect from 'ember-redux/components/connect';
const stateToComputed = (state) => {
return {
numberOfTypes: state.cart.length,
totalCartCount: state.cart.reduce((totalCount, product) => totalCount += product.count, 0),
cartItems: state.cart
};
};
@alexlafroscia
alexlafroscia / README.md
Last active August 6, 2018 19:13
Skate.js ShadyCSS Mixin

ShadyCSS Skate.js Mixin

Out of the box, Skate.js doesn't work that well with ShadyCSS. This is a mixin that helps bridge the gap.

Usage

The usage example below assumes you're using a build tool like Webpack to transform a CSS file into a string when loaded.

import Component from 'skatejs';
@alexlafroscia
alexlafroscia / controllers.application.js
Last active January 26, 2017 18:10
Dismiss popover on link focus-out
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
popoverVisible: false,
actions: {
showPopover() {
this.set('popoverVisible', true);
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@alexlafroscia
alexlafroscia / controllers.application.js
Last active December 7, 2016 22:38
ember-block-slots vs Ember v2.10.0
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
function asyncComputed(...deps) {
let taskFn = deps.pop();
let fn = task(taskFn).restartable().toFunction();
return Ember.computed(...deps, function() {
let args = deps.map(dep => this.get(dep));
return fn(...args);
});