Skip to content

Instantly share code, notes, and snippets.

View brandonroberts's full-sized avatar

Brandon Roberts brandonroberts

View GitHub Profile
@brandonroberts
brandonroberts / index.ts
Created May 24, 2021 13:12
My-Schematic Generate Files
import { Tree, convertNxGenerator, generateFiles, joinPathFragments, names, readJson } from '@nrwl/devkit';
export function mySchematicGenerator(tree: Tree, opts: any) {
const workspace = readJson(tree, 'angular.json');
if (!opts.project) {
opts.project = workspace.defaultProject;
}
const project = workspace.projects[opts.project];
@brandonroberts
brandonroberts / workspace.json.diff
Last active May 26, 2021 15:10
Target Deps Build/Serve Example
"app1": {
"targets": {
"build": {},
"serve": {
+ "dependsOn": [{
+ "target": "build",
+ "projects": "self"
+ }]
}
}
@brandonroberts
brandonroberts / workspace.json
Last active May 12, 2021 18:01
Target Deps Previous Version
{
"projects": {
"app1": {
"targets": {
"build": {
...
}
}
},
"lib1": {
@brandonroberts
brandonroberts / workspace.json.diff
Last active May 26, 2021 15:11
Target Deps Example 1
{
"projects": {
"app1": {
"targets": {
"build": {
+ "dependsOn": [{
+ "target": "build",
+ "projects": "dependencies"
+ }]
}
@brandonroberts
brandonroberts / title.effects.ts
Created May 10, 2021 10:49
Page Title Effect w/concatLatestFrom
import { Injectable } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { map, tap } from 'rxjs/operators';
import {Actions, concatLatestFrom, createEffect, ofType} from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { routerNavigatedAction } from '@ngrx/router-store';
import * as fromRoot from './reducers';
@Injectable()
export class RouterEffects {
@brandonroberts
brandonroberts / go-project-graph.js
Created May 5, 2021 15:35
Go Project Graph Plugin
const { DependencyType, ProjectGraphBuilder } = require('@nrwl/devkit');
const execa = require('execa');
const { join } = require('path');
exports.processProjectGraph = (graph, context) => {
const builder = new ProjectGraphBuilder(graph);
const completedSubprocess = execa.sync('go', [
'run',
join(__dirname, 'get-package-metadata.go'),
@brandonroberts
brandonroberts / nx.json
Created May 5, 2021 15:33
Go Projects In an Nx worksapce
{
"npmScope": "nx-go-project-graph-plugin",
"plugins": ["./tools/project-graph-plugins/go-project-graph.js"],
"projects": {
"libs-pkg-hello": { "tags": [] },
"executables-cmd-hello": { "tags": [] },
"executables-services-hello": { "tags": [] }
}
}
@brandonroberts
brandonroberts / Every possible TypeScript type.md
Created January 5, 2021 00:06 — forked from laughinghan/Every possible TypeScript type.md
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything at all is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.

Everything I Know About UI Routing

Definitions

  1. Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
    1. pathname - The "file/directory" portion of the URL, like invoices/123
    2. search - The stuff after ? in a URL like /assignments?showGrades=1.
    3. query - A parsed version of search, usually an object but not a standard browser feature.
    4. hash - The # portion of the URL. This is not available to servers in request.url so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things.
    5. state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
@brandonroberts
brandonroberts / ngrx.ts
Created August 22, 2019 19:44
NgRx Store Example
@Injectable()
export class AccountService {
constructor(private http: HttpClient, private store: Store<{}>) {}
getAccountsData() {
this.http.get('/someUrl')
// .pipe(tap(response => {
// this.store.dispatch({ type: 'LoadAccountsSuccess', data: response });
// })).subscribe();
}