Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect closure in V1Meta.prototype.query - a multi result query duplicates the last result #11

Open
jamesjenner opened this issue Aug 25, 2014 · 1 comment

Comments

@jamesjenner
Copy link

Hi Guys,

I've just discovered the SDK and am exploring developing 10 foot interfaces for our teams.

I'm using an adapted query example and I have found all results are a duplication of the last result.

This is caused by the generated javascript code within V1Meta.prototype.query.

The problem is highlighted below:

        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          assetxml = _ref[_i];

          ...                
          _results.push(_this.get_asset_class(found_type, function(err, Cls) {

            ...

            asset = _this.build_asset(Cls, assetxml);

            return options.success(asset);
          }));
        }

Inside the _this.get_asset_class() callback, the variable assetxml will always reference the value of _i on the last iteration as the scope of _i is to the function.

I'm not familiar with coffee script, so I cannot help you with the V1Meta.coffee source, but hopefully what I've pointed you towards will help.

@jamesjenner
Copy link
Author

A previous issue has multiple issues listed in it. Unfortunately I didn't realise until I had posted this. To make it clearer, I think this issue should remain, as it's not obvious when browsing the unresolved issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant