diff --git a/CHANGELOG.md b/CHANGELOG.md index af8d65417..b42e4c0f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -166,6 +166,7 @@ See [#640](https://github.com/mobxjs/mobx/issues/640) * Passing a function to `observable` will now create a boxed observable refering to that function * Deprecated `whyRun` (as it seems hardly used, please let us know if it should stay) * Fixed #603: exceptions in transaction breaks future reactions +* Fixed #698: createTransformer should support default arguments * The following deprecated methods have been removed: * `autorunUntil` * `trackTransitions` diff --git a/src/api/createtransformer.ts b/src/api/createtransformer.ts index 79233ebf8..87f700d06 100644 --- a/src/api/createtransformer.ts +++ b/src/api/createtransformer.ts @@ -5,7 +5,7 @@ import {globalState} from "../core/globalstate"; export type ITransformer = (object: A) => B; export function createTransformer(transformer: ITransformer, onCleanup?: (resultObject: B | undefined, sourceObject?: A) => void): ITransformer { - invariant(typeof transformer === "function" && transformer.length === 1, "createTransformer expects a function that accepts one argument"); + invariant(typeof transformer === "function" && transformer.length < 2, "createTransformer expects a function that accepts one argument"); // Memoizes: object id -> reactive view that applies transformer to the object let objectCache: {[id: number]: ComputedValue} = {};