ng new -p --minimal true --service-worker true --view-encapsulation OnPush --routing true --style scss
This file contains hidden or 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 enum ActionState { | |
| INIT = "[ActionState] INIT", | |
| OK = "[ActionState] OK", | |
| ERROR = "[ActionState] ERROR", | |
| } | |
| export interface BaseAction <G, A extends ActionState, P = void> { | |
| readonly group: G; | |
| readonly state: A; |
This file contains hidden or 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 { map, filter, reduce, assign } from 'lodash'; | |
| /** | |
| * Map over a tree from the bottom-most nodes up. Applies transformation to deepest children, | |
| * then to parents, and so on. You can even rename the property that contains the children. | |
| * | |
| * Usage: | |
| * tmap( | |
| * x => ({ ...x, value: x.value + 1 || 0 }), | |
| * 'children', |
This file contains hidden or 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
| type Complement<A, B> = { | |
| [Key in keyof A]: Key extends keyof B ? never : A[Key] | |
| }; | |
| // Simple Cascade | |
| const cascade = <A>(a: A) => <B>(b: Complement<B, A>): A & B => | |
| Object.assign({}, a, b); | |
| const c1 = cascade({ key1: 1 }); | |
| const c2 = c1({ key1: 2 }); // Type error, key1 must be never | |
| const c3 = c1({ key2: 2 }); // Has type { key1: number, key2: number } |
This file contains hidden or 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 { useContext, useEffect, Context, useState } from 'react'; | |
| import { Store } from 'redux'; | |
| /** | |
| * Creates a useRedux hook. | |
| * | |
| * First function takes Context. | |
| * | |
| * Second function takes a selector and an optional comparator and | |
| * returns the output of the selector and the store's dispatch function |
This file contains hidden or 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
| // A function that operates like a ternary operator but can be lazy | |
| export type CascadePair<S, C = boolean> = [C, S]; | |
| export const cascade = <T>(...cases: CascadePair<T>[]) => { | |
| const match = cases.find(c => c[0]); | |
| return match !== undefined ? match[1] : undefined; | |
| }; | |
| export const cascadeOrElse = <T>(def: T, ...cases: CascadePair<T>[]) => { | |
| const match = cascade(...cases); |
This file contains hidden or 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
| npm i @nll/{css,rx-fsa} lodash react react-dom redux | |
| npm i -D @nll/schematics-react @types/{lodash,node,react,react-dom,redux} parcel-bundler typescript |
This file contains hidden or 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 del from 'rollup-plugin-delete'; | |
| import typescript from 'rollup-plugin-typescript'; | |
| import resolve from 'rollup-plugin-node-resolve'; | |
| import commonjs from 'rollup-plugin-commonjs'; | |
| import htmlTemplate from 'rollup-plugin-generate-html-template'; | |
| import copy from 'rollup-plugin-copy'; | |
| import serve from 'rollup-plugin-serve'; | |
| import { terser } from 'rollup-plugin-terser'; | |
| const createHash = () => |
This file contains hidden or 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 { Pipe, PipeTransform } from '@angular/core'; | |
| import { map } from 'lodash'; | |
| import { tryCatchEither } from '@loda/utils'; | |
| interface MapTransform { | |
| <T, D>(value: T, iteratee: (t: T) => D): D | T; | |
| <T, D>(value: T[], iteratee: (t: T) => D): D[] | T[]; | |
| } |
This file contains hidden or 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 { h, FunctionalComponent, render, options } from 'preact'; | |
| import { handleVnode } from './hooks'; | |
| // Wireup experimental hooks | |
| options.vnode = handleVnode; | |
| import Test from './component'; | |
| export const Main: FunctionalComponent<any> = () => ( |