Skip to content

Commit

Permalink
Fixes #698, create transform accepts funcs with default args
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Dec 31, 2016
1 parent af6ec68 commit 7f859eb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion src/api/createtransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {globalState} from "../core/globalstate";
export type ITransformer<A, B> = (object: A) => B;

export function createTransformer<A, B>(transformer: ITransformer<A, B>, onCleanup?: (resultObject: B | undefined, sourceObject?: A) => void): ITransformer<A, B> {
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<B>} = {};
Expand Down

0 comments on commit 7f859eb

Please sign in to comment.