test: wip tests for observer

This commit is contained in:
Evan You
2018-09-19 17:45:19 -04:00
parent 7350d41f92
commit 26ff9b29f9
11 changed files with 891 additions and 74 deletions

View File

@@ -32,12 +32,13 @@ export type Debugger = (event: DebuggerEvent) => void
export const activeAutorunStack: Autorun[] = []
const ITERATE_KEY = Symbol('iterate')
export const ITERATE_KEY = Symbol('iterate')
export function createAutorun(fn: Function, options: AutorunOptions): Autorun {
const runner = function runner(...args): any {
return run(runner as Autorun, fn, args)
} as Autorun
runner.isAutorun = true
runner.active = true
runner.raw = fn
runner.scheduler = options.scheduler

View File

@@ -24,6 +24,7 @@ import {
} from './autorun'
export { Autorun, DebuggerEvent }
export { OperationTypes } from './operations'
export { computed, ComputedGetter } from './computed'
export { lock, unlock } from './lock'
@@ -40,7 +41,7 @@ const canObserve = (value: any): boolean => {
)
}
type identity = <T>(target: T) => T
type identity = <T>(target?: T) => T
export const observable = ((target: any = {}): any => {
// if trying to observe an immutable proxy, return the immutable version.