Skip to content

Instantly share code, notes, and snippets.

@rottenoats
Created June 29, 2018 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rottenoats/7908b5c8d36ad47bb28c42f8e542a29a to your computer and use it in GitHub Desktop.
Save rottenoats/7908b5c8d36ad47bb28c42f8e542a29a to your computer and use it in GitHub Desktop.
import { IEnhancer, IObservableArray, IObservableDecorator, IObservableMapInitialValues, IObservableObject, IObservableValue, ObservableMap } from "../internal";
export declare type CreateObservableOptions = {
name?: string;
deep?: boolean;
defaultDecorator?: IObservableDecorator;
proxy?: boolean;
};
export declare const defaultCreateObservableOptions: CreateObservableOptions;
export declare function asCreateObservableOptions(thing: any): CreateObservableOptions;
export declare const deepDecorator: IObservableDecorator;
export declare const refDecorator: IObservableDecorator;
export interface IObservableFactory {
(value: number | string | null | undefined | boolean): never;
(target: Object, key: string | symbol, baseDescriptor?: PropertyDescriptor): any;
<T = any>(value: T[], options?: CreateObservableOptions): IObservableArray<T>;
<K = any, V = any>(value: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
<T extends Object>(value: T, decorators?: {
[K in keyof T]?: Function;
}, options?: CreateObservableOptions): T & IObservableObject;
}
export interface IObservableFactories {
box<T = any>(value?: T, options?: CreateObservableOptions): IObservableValue<T>;
array<T = any>(initialValues?: T[], options?: CreateObservableOptions): IObservableArray<T>;
map<K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
object<T = any>(props: T, decorators?: {
[K in keyof T]?: Function;
}, options?: CreateObservableOptions): T & IObservableObject;
/**
* Decorator that creates an observable that only observes the references, but doesn't try to turn the assigned value into an observable.ts.
*/
ref: IObservableDecorator;
/**
* Decorator that creates an observable converts its value (objects, maps or arrays) into a shallow observable structure
*/
shallow: IObservableDecorator;
deep: IObservableDecorator;
struct: IObservableDecorator;
}
export declare const observable: IObservableFactory & IObservableFactories & {
enhancer: IEnhancer<any>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment