Skip to content

Instantly share code, notes, and snippets.

/* tslint:disable:no-unused-variable */
type booleanify<T> = { [P in keyof T]: boolean };
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { AppState, Store, dataReducer, DataActions, MiscActions } from '../../../cdux';
import { async, inject } from '@angular/core/testing';
import * as moment from 'moment';
import { ProcedureSchedulerComponent } from '../../../component/scheduleTools/procedureScheduler/procedureScheduler.component';
@Devcon4
Devcon4 / Action.ts
Last active May 30, 2018 16:30
Example of state
export class Action<T> {
_subject = new BehaviorSubject<T>(undefined);
public get state() : T {
return this._subject.getValue();
}
public set state(v : T) {
this._subject.next(v);
getCitation = this.ds.citation.getAllForProcedure.bind(this, pipe(Dispatch(this.store, this.getCitation), Spinner(this.store)));
getCitations(procId: number): Observable<CitationBasic> {
return this.httpGet(
this.getCitations,
'/inspections/api/action/Citation/GetAllForProcedure?procId=' + procId,
x => new CitationBasic(x)
);
}
@Devcon4
Devcon4 / action.ts
Last active November 7, 2020 23:30
httpClient
export class Action<T> {
_subject = new BehaviorSubject<T>(undefined);
public get state() : T {
return this._subject.getValue();
}
public set state(v : T) {
this._subject.next(v);
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
type rule<T> = {[key in FunctionPropertyNames<T>]?: T[key] extends (args: infer U) => void ? U : never};
class rules {
ruleOne(args: {first: string, second: number}) { }
}
function ruleTwo(args: {first: number}) { }
@Devcon4
Devcon4 / plugin.ts
Created April 24, 2018 02:17
Fun with dynamic literals!
const number = /(?:sbyte|ushort|short|uint|int|ulong|long|float|double|decimal|byte)/;
const string = /(?:char|string)/;
const bool = /(?:bool)/;
const date = /(?:DateTime)/;
let builder = {
accessModifier: 'public',
name: 'test',
type: 'int'
};