Last active
August 29, 2015 14:07
-
-
Save radicaled/a0bff41189de3e766e5a to your computer and use it in GitHub Desktop.
dart:js interop problems.
This file contains 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
void map(doc, emit) { | |
emit(doc); // emit all documents | |
} | |
var db = new JsObject(context['PouchDB'], ['test_db']); | |
var jsPromise = db.callMethod('query', [map]); | |
// map ends up being wrapped like this: | |
// function () { return func(Array.prototype.slice.apply(arguments)); } |
This file contains 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
// PouchDB is expecting a function like this: | |
// function(doc, emit) { /* ... */ } | |
// but Dart is sending this: | |
// function () { return func(Array.prototype.slice.apply(arguments)); } | |
// | |
// Thus triggers the second branch. | |
if (typeof view.mapFun === "function" && view.mapFun.length === 2) { | |
var origMap = view.mapFun; | |
mapFun = function (doc) { | |
return origMap(doc, emit); | |
}; | |
} else { | |
mapFun = evalFunc(view.mapFun.toString(), emit, sum, log, Array.isArray, JSON.parse); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment