Skip to content

Instantly share code, notes, and snippets.

export function ContentChildrenChanges() {
return function (target, propertyKey) {
if (!isContentChanges(target)) {
return;
}
// Grab reference to toriginal `ngOnDestroy()` hook
import { Injectable, Inject } from "@angular/core";
import { ParsedUrl } from './url/url.interfaces';
import { AppResolverOptions, APP_RESOLVER_OPTIONS } from './app-launcher.interfaces';
@Injectable()
export class AppResolver {
constructor(
@Inject(APP_RESOLVER_OPTIONS) private options: AppResolverOptions
) {}
import { createSelector } from '@ngrx/store';
import { State } from './reducer.ts';
export const selectTodosCount = createSelector((state: State): number => {
return Object.keys(state).length;
});
@dherges
dherges / reducer.ts
Last active May 11, 2018 13:15
Reducer
import { Todo } from './model';
export interface State {
[id: string]: Todo
}
export function reducer(state: State, action): State {
switch (action.type) {
case Types.ADD_TODO:
const id = action.payload.id;
@dherges
dherges / ng-build.sh
Created January 12, 2018 16:23
ng build
$ ng build --app foo && ng build --app bar && ng build --app foo-bar
Date: 2018-01-12T16:08:36.058Z
Hash: c74c6a1b18230624c8ba
Time: 7337ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 8.33 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 201 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.4 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.43 MB [initial] [rendered]
Date: 2018-01-12T16:08:45.721Z
@dherges
dherges / mvn-install.sh
Created January 12, 2018 16:22
mvn install
$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] minimal-pom
[INFO] angular-product-bar
[INFO] angular-product-foo
[INFO] angular-product-foo-bar
[INFO]
@dherges
dherges / eventbus.ts
Created January 4, 2018 07:13
Event Bus on RxJS
export type MyStuff = string;
export interface Event<T> {
type: 'Starts' | 'Finishes',
payload: T
}
/** @experimental */
export class Bus<P> extends Subject<Event<P>> {
@dherges
dherges / flat-module.metadata.json
Created December 9, 2017 09:01
ng-packagr #382
{
"__symbolic": "module",
"version": 4,
"metadata": {
"SelectableListModule": {
"__symbolic": "class",
"decorators": [
{
"__symbolic": "call",
"expression": {
@dherges
dherges / typescript.d.ts
Last active November 12, 2017 18:23
TypeScript Transformations API
/**
* Visits a Node using the supplied visitor, possibly returning a new Node in its place.
*/
function visitNode<T extends Node>(node: T, visitor: Visitor): T;
/**
* Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in
* its place.
*/
function visitNodes<T extends Node>(nodes: NodeArray<T>, visitor: Visitor): NodeArray<T>;
@dherges
dherges / function-works.component.ts
Created October 11, 2017 18:29
Angular: Componentful Functions
@Component({
selector: 'app-function-works',
templateUrl: './function-works.component.html',
styleUrls: ['./function-works.component.css']
})
export class FunctionWorksComponent implements OnInit {
message = 'foo';
constructor() { }