Skip to content

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

Open

Description

@jamesjenner

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.

Activity

  1. jamesjenner commented on Aug 25, 2014

    @jamesjenner
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions