This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface CustomElementConfig { | |
tagName: string; | |
options?: { | |
extends: string; | |
}; | |
} | |
/** | |
* @CustomElement({ | |
* tagName: 'my-element' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fallback = require('express-history-api-fallback'); | |
var express = require('express'); | |
var compress = require('compression'); | |
var app = express(); | |
var root = __dirname + '/dist'; | |
app.use(compress()); | |
app.use(express.static(root)); | |
app.use(fallback('index.html', { root: root })); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myWorker = $worker().create(function () { | |
self.postMessage('Hello World'); | |
}); | |
myWorker.run().then(function (e) { | |
console.log(e.data); // 'Hello World' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Standard Service Class | |
export class MyService { | |
constructor(private config) { } | |
} | |
// factory for creating new instances of the service | |
function createMyService(config = {}) { | |
return new MyService(config); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
class NameCard extends HTMLElement { | |
set name(val) { | |
this._name = val; | |
this.render(); | |
} | |
get name() { | |
return this._name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createWorker(fn) { | |
var blob = new Blob(['self.onmessage = ', fn.toString()], { type: 'text/javascript' }); | |
var url = URL.createObjectURL(blob); | |
return new Worker(url); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core'; | |
@Component({ | |
selector: 'my-app', | |
template: ` | |
<div class="map-container" #mapContainer><div> | |
`, | |
styles: [` | |
.map-container { | |
height: 300px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/app.components.ts | |
import {AppComponent} from './app.component'; | |
import {Injector} from '@angular/core'; | |
import {expect, it, describe, beforeEach, beforeEachProviders, inject} from '@angular/core/testing'; | |
describe('Component: AppComponent should be created', function () { | |
let fooComponent: FooComponent; | |
beforeEachProviders(() => [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BehaviorSubject, of } from 'rxjs'; | |
import { distinctUntilChanged, concatMap, map, take } from 'rxjs/operators'; | |
export class StateDef<T> extends BehaviorSubject<T> { | |
setState(setter: (state: T) => T) { | |
this.pipe(take(1)).subscribe(state => { | |
super.next(setter(state)); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import core testing libs | |
import { | |
beforeEach, | |
addProviders, | |
it, | |
describe, | |
expect, | |
inject | |
} from '@angular/core/testing'; |