Skip to content

Instantly share code, notes, and snippets.

Alex Matchneer machty

Block or report user

Report or block machty

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
View components.async-button.js
import Ember from 'ember';
export default Ember.Component.extend({
tagName: '',
});
View controllers.application.js
import Ember from 'ember';
import { task, timeout, waitForProperty } from 'ember-concurrency';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
lol: false,
foo: task(function * () {
this.set('lol', false);
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
get foo() {
return "i was returned from the getter foo";
}
});
@machty
machty / router-js-refactor-architecture.md
Last active Jul 31, 2019
Overview of the architecture and approach to the router.js refactor
View router-js-refactor-architecture.md

router.js Architecture

Let this serve as a guide for anyone who'd like to dig into router.js's internals, understand what's going on, and hopefully contribute!

Scope of router.js (et al)

router.js is most popularly known as the routing microlib used by the Ember.js Router, though other folk have been known to use it beyond Ember, including some Angular folk who weren't satisfied with

@machty
machty / ember-cli-build.js
Last active Jul 15, 2019
Broccoli challenges
View ember-cli-build.js
/* jshint node: true */
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const generateWhitelabelIndexes = require('./generate-whitelabel-indexes');
module.exports = function(defaults) {
const app = new EmberApp(defaults, {
// ...all sorts of config
});
View controllers.application.js
import Ember from 'ember';
import { task, timeout, waitForProperty } from 'ember-concurrency';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
count: 0,
foo: task(function() {
return {
@machty
machty / document-title-router.js
Created Jan 14, 2014
document.title integration in ember
View document-title-router.js
// Extend Ember.Route to add support for sensible
// document.title integration.
Ember.Route.reopen({
// `titleToken` can either be a static string or a function
// that accepts a model object and returns a string (or array
// of strings if there are multiple tokens).
titleToken: null,
@machty
machty / e-c-observable-integration.md
Created Nov 26, 2016
ember-concurrency observable integration thoughts
View e-c-observable-integration.md

Observable integration

Lots of FPR libraries use Observables as their central async/concurrency primitive, so it'd be nice if ember-concurrency could integrate with these libraries.

Before delving into how this might be possible, here's a quick compare/contrast between e-c Tasks and Observables:

  • Modeling Streams
    • both e-c tasks and observables can async streams of zero or more values followed by an optional success/error termination
      • observables emit values using onNext(), onCompleted(), and onError()
      • tasks emit values using emit(), and returning a value from a generator fn is an implicit emit(), and throwing an error is an implicit onError
View controllers.application.js
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: {
You can’t perform that action at this time.