Skip to content

Instantly share code, notes, and snippets.

Avatar

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
mhevery / microsyntax.md
Last active Sep 21, 2020
Angular microsyntax gramar
View microsyntax.md

Microsyntax

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.

Constraints

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
mhevery / Zone.md
Last active Aug 12, 2020
TC39 Zone Proposal
View Zone.md

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
mhevery / examples.md
Last active Jul 27, 2017
TC39 Zone API Proposal
View examples.md

Monkey patching common browser APIs

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

setTimeout

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

window.setTimeout = ((delegate) => {
@mhevery
mhevery / example.ts
Last active Jun 1, 2017
Angular2: NgProbe Design
View example.ts
// https://gist.github.com/mhevery/4b1bdb59a8c16f9cbe76
/// <reference path="probe.d.ts" />
///////////////////////
/// WORK IN PROGRESS //
///////////////////////
var appRef: ApplicationRef = ng.platform.applications[0];
View dartUpgrade.sh
#!/bin/sh
curl http://storage.googleapis.com/dart-archive/channels/dev/release/latest/editor/darteditor-macos-x64.zip > ~/Downloads/darteditor-macos-64-dev.zip;
echo Fetched new dart version $(unzip -p ~/Downloads/darteditor-macos-64-dev.zip dart/dart-sdk/version)
rm -rf /Applications/dart-dev ;
unzip ~/Downloads/darteditor-macos-64-dev.zip -d /tmp > /dev/null
mv /tmp/dart /Applications/dart-dev
curl http://storage.googleapis.com/dart-archive/channels/stable/release/latest/editor/darteditor-macos-x64.zip > ~/Downloads/darteditor-macos-64.zip;
echo Fetched new dart version $(unzip -p ~/Downloads/darteditor-macos-64.zip 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>
<head>
<script type="text/javascript" src="http://code.angularjs.org/1.0.0rc12/angular-1.0.0rc12.min.js"></script>
<script>
function Test($scope, $location) {
$scope.away = 'away';
}
</script>
</head>
<body ng-controller="Test">
View gist:1903387
<!doctype html>
<html xmlns:ng="http://angularjs.org" ng:app>
<script src="http://docs-next.angularjs.org/angular-0.10.6.min.js"></script>
<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.