Skip to content

Instantly share code, notes, and snippets.


Miško Hevery mhevery

View GitHub Profile
View FEATURE REQUEST: improve inline edits
# Overview
Github has a feature where the reviewer can suggest inline edits to a PR in side of a comment.
This is super usefull feature. PR owner can than accept these changes by accepting the suggestions and merging
them into the PR directly from the UI.
mhevery /
Last active Sep 21, 2020
Angular microsyntax gramar


Microsyntax in Angular allows you to write <div *ngFor="let item of items">{{item}}</div> instead of <ng-template ngFor [ngForOf]="items"><div>{{item}}</div></ng-template.


The microsyntax must:

  • be know ahead of time so that IDEs can parse it without knowing what is the underlying semantics of the directive or what directives are present.
  • must translate to key-value attributes in the DOM.
View zone.js.d.ts
* Zone is a mechanism for intercepting and keeping track of asynchronous work.
* A Zone is a global object which is configured with rules about how to intercept and keep track
* of the asynchronous callbacks. Zone has these responsibilities:
* 1. Intercept asynchronous task scheduling
* 2. Wrap callbacks for error-handling and zone tracking across async operations.
* 3. Provide a way to attach data to zones
* 4. Provide a context specific last frame error handling
mhevery /
Last active Aug 12, 2020
TC39 Zone Proposal

Zone Motivation

Make writing asynchronous code easier by having a consistent way of propagating "context" across related asynchronous operations. Have the "context" be responsible for async-local-storage, allowing the execution before and after hooks, and "context"-local error handling. Finally make sure that the "context"s are composable.

This feature needs to be part of the platform so that library and framework authors can relay on a common well know API, otherwise adoption will be limited.

mhevery /
Last active Jul 27, 2017
TC39 Zone API Proposal

Monkey patching common browser APIs

Here is an example of how browser APIs could be patched to take advantage of Zone propagation.


Ideally we would not need to do this, since the browser would do this for us.

window.setTimeout = ((delegate) => {
mhevery / example.ts
Last active Jun 1, 2017
Angular2: NgProbe Design
View example.ts
/// <reference path="probe.d.ts" />
var appRef: ApplicationRef = ng.platform.applications[0];
curl > ~/Downloads/;
echo Fetched new dart version $(unzip -p ~/Downloads/ dart/dart-sdk/version)
rm -rf /Applications/dart-dev ;
unzip ~/Downloads/ -d /tmp > /dev/null
mv /tmp/dart /Applications/dart-dev
curl > ~/Downloads/;
echo Fetched new dart version $(unzip -p ~/Downloads/ dart/dart-sdk/version)
rm -rf /Applications/dart ;
View gist:7092098
When you go to bleeding edge you should change to:
@NgController {
selector: '[ng-controller=AppointmentCtrl]',
publishAs: 'ctrl'
class AppointmentCtrl {
String appointmentText = '';
List appointments = [{'time': '08:00', 'title': 'Wake Up'}];
View angular-issue-1051.html
<html ng-app>
<script type="text/javascript" src=""></script>
function Test($scope, $location) {
$scope.away = 'away';
<body ng-controller="Test">
View gist:1903387
<!doctype html>
<html xmlns:ng="" ng:app>
<script src=""></script>
function MainCntl($route, $routeParams, $location) {
this.$route = $route;
this.$location = $location;
this.$routeParams = $routeParams;
$route.when('/Book/:bookId', {template: 'examples/book.html', controller: BookCntl});
You can’t perform that action at this time.