Skip to content

Using .property on maps defined by keyBy should return original variable instance #54

@kcrwfrd

Description

@kcrwfrd

Is it possible/desirable for maps generated by keyBy to return original variable instances?

class Foo extends Variable<{ Name: string, Id: number }> {}
const Collection = VArray.of(Foo)

const collection = new Collection([{
  Name: 'Kerry',
  Id: 123
}])

const index = collection.keyBy(model => model.get('Id'))

// fails
assert.strictEqual(index.property(123), collection.property(0))

// fails
assert(index.property(123) instanceof Foo)

let newProps = {
  Name: 'Jerry',
  Id: 123,
} 

index.set(123, newProps)

// fails
assert.strictEqual(collection.get(0), newProps)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions