Skip to content

Instantly share code, notes, and snippets.

View machty's full-sized avatar

Alex Matchneer machty

View GitHub Profile
@machty
machty / resolvers.md
Created April 9, 2013 03:06
context resolvers

Context Resolvers

Why: because transitionTo and handleURL are fundamentally different, and you don't want to automatically deserialize everything all at once, so the idea is that routeTo handlers only get contextResolver objects.

@machty
machty / router.md
Last active December 16, 2015 00:49
The smallest possible router refinement.

Proposal

  1. No longer encourage/allow external calls to a Route's transitionTo method.
  2. Instead, make use of a new routeTo event, with the same semantics as transitionTo, only that it's an event that routes can respond to.
  3. ApplicationRoute will have a default routeTo handler which passes its args to an internal transitionTo.
  4. URL changes will be converted into a routeTo event event.
@machty
machty / stef-questions.md
Last active December 16, 2015 05:29
router questions/clarifications post Stef discussion

Scenario: routeTo with promise-like contexts

  1. router.send('routeTo', 'posts.show', Post.find(123));
  2. Post.find(123) returns an Ember.Deferred, an object with a .then property.
  3. The router sends the routeTo event up the route hierarchy.
  4. If no one else handles it beforehand, the default routeTo handler injected into ApplicationRoute will. This is where we can define default application-wide transitioning behavior.

One major question that remains is: how do we handle promise contexts?

Alex says:

@machty
machty / correct-macvim-app.html
Created April 18, 2013 14:40
:TOhtml command producing different results for `vim-emblem` plugin. Works on MacVim app, not on MacVim terminal version http://f.cl.ly/items/193A3K2S2X1y3F0H353D/Screen%20Shot%202013-04-18%20at%2010.39.21%20AM.png
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>~/asd.emblem.html</title>
<meta name="Generator" content="Vim/7.3">
<meta name="plugin-version" content="vim7.3_v10">
<meta name="syntax" content="emblem">
<meta name="settings" content="number_lines,use_css,expand_tabs">
<style type="text/css">
@machty
machty / macvimapp.html
Created April 18, 2013 14:53
Notice how both have the `rubyDefine` but only macvim app has Type Identifier and Constant
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>~/borf.rb.html</title>
<meta name="Generator" content="Vim/7.3">
<meta name="plugin-version" content="vim7.3_v10">
<meta name="syntax" content="ruby">
<meta name="settings" content="number_lines,use_css,expand_tabs">
<style type="text/css">

Router Goals / Proposal

  1. Backwards-compatibility with existing router/transition behavior.
  2. All transitions funneled through a transitionTo event.
  3. Inject default transitionTo handler into ApplicationRoute events hash, which will call router.js's transitionTo.
  4. All other external transitionTo, transitionToRoute API will convert to transitionTo event.

Transition Behaviors Involving Promise Contexts

@machty
machty / router-roadmap.md
Last active December 16, 2015 12:49
Roadmap for past/ongoing/future changes to `Ember.Router`

Ultimate Goals for 1.0.0 Ember Router (if possible, else 1.1)

  1. Sound state-machine-based approach to transitions
  2. Configurable/overridable defaults for handling transitions involving promise-y contexts
  3. Full backwards compatibility with present API

Roadmap

Event-ize transitionTo PR 2552

@machty
machty / router-use-cases.md
Last active December 16, 2015 15:29
A collection of use cases that Ember Router ought to support. Some of these may presently be implemented, but to varying degrees of quality/configurability/jankness; either way, the implementation may change so it's important that we preserve existing use cases. Also, not all of these needed to be specifically handled by Ember Core; rather, the …

Prevent transition when a form is half filled out

If you've filled out some fields in a navigate elsewhere, either via a back button, URL change, or linkTo transition, there should be a way to intercept that transition and make the user confirm they want to perform the transition.

Answer

Use routeTo handler on form route. Bubble the event if user confirms navigation.

Delayed "Twitter" transition, regardless of URL navigation / transitionTo

This is a big header

Here is a some text in a paragraph. This is still in the same paragraph.

This is a separate paragraph. Also, this paragraph has italicized words. And it also has some bold words too.

This is a slightly smaller header

@machty
machty / double-finally-safari.js
Last active December 17, 2015 04:18
Run in Safari 6.0.2. Demonstrates yet another bizarre scenario for the double finally bug in Safari, but in this setup, the outer finally only fires once; apparently that buggy behavior gets occasionally cancelled by the outer catch? But in the commented example without the catch, the outer finally fires twice.
try{
try {
try { }
finally {
alert('inner');
throw new Error('ERROR INNER');
}
}
finally {
alert('outer');