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
/** | |
* Created by buhi on 2017/7/11. | |
*/ | |
import * as React from "react" | |
import {Grid,GridFieldSchema,GridProps} from "ag-grid-material-preset"; | |
import {IGetRowsParams} from "ag-grid/dist/lib/rowModels/iDatasource"; | |
import {GridApi} from "ag-grid/dist/lib/gridApi"; | |
import {List,Repeat} from "immutable"; | |
type InfiniteScrollGridProps = { |
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 function $exportCSV(csv, filename) { | |
const blobObject = new Blob(["\ufeff", csv], { | |
type: "text/csv;charset=utf-8;" | |
}); | |
// Internet Explorer | |
if (navigator.msSaveOrOpenBlob) { | |
navigator.msSaveOrOpenBlob(blobObject, filename); | |
} else { | |
// Chrome |
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 { createBrowserHistory } from "history"; | |
import { BehaviorSubject } from 'rxjs'; | |
import * as React from "react" | |
type RouteConfig<P=any> = { | |
key:string, | |
label?:string, | |
icon?:string, | |
component?:()=>Promise<{default:React.ComponentType<P>}>, | |
} |
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 * as React from "react"; | |
const ERROR_DETAIL = Symbol("errors") | |
const HAS_ERROR = Symbol("has error") | |
const InternalSymbolKeys = [ERROR_DETAIL,HAS_ERROR] | |
enum FieldType { | |
arrayItem, | |
property, |
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 { | |
createProgram, | |
SourceFile, | |
isImportDeclaration, | |
createCompilerHost, | |
CompilerOptions, | |
ModuleKind, | |
ModuleResolutionKind, | |
ScriptTarget, | |
resolveModuleNameFromCache, |
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
/** | |
* some insane hack, just want to avoid using expensive parser. | |
*/ | |
export function getFreeVariables(expr:string, knownSymbols:Record<string,unknown>){ | |
const freeVariables = new Set<string>(); | |
//eslint-disable-next-line | |
const anyThingPrimitive = ()=>{}; |
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
window.servicemap = new Map() | |
class A { | |
constructor(){ | |
console.log("A created") | |
} | |
} | |
function useService(A){ | |
let a = servicemap.get(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 { Observable, SubscribableOrPromise } from "rxjs" | |
import { switchMap, tap } from "rxjs/operators" | |
export type collectedResponse<T2> = { loading: boolean; error: null | Error; value: null | T2 } | |
export function collectResponse<T1, T2>(performRequest: (t1: T1) => SubscribableOrPromise<T2>) { | |
return (observer: Observable<T1>)=>{ | |
let lastResponse = null as null | T2 | |
return new Observable<collectedResponse<T2>>(subscriber=>{ | |
return observer.pipe( |
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 { BehaviorSubject, Observable, Subscription, SubscribableOrPromise, from } from "rxjs" | |
import { skip } from "rxjs/operators" | |
import * as React from "react" | |
import { useSubscription } from "use-subscription" | |
type ObservedValueOf<T> = T extends BehaviorSubject<infer U1> ? U1 : T extends Observable<infer U2> ? U2 | null : never | |
export function useObservables<T>(ob: T | undefined | null): [ObservedValueOf<T>] | |
export function useObservables<T1, T2>(ob1: T1 | undefined | null, ob2: T2 | undefined | null): [ObservedValueOf<T1>, ObservedValueOf<T2>] | |
export function useObservables<T1, T2, T3>( |
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
//Idea is borrowed from https://github.com/gnaeus/react-ioc | |
//Differences are: | |
//1. Does not require reflect-metadata | |
//2. Has an additional "useProvider" method | |
import * as React from "react" | |
export interface Disposable { | |
dispose?(): void | |
} |
OlderNewer