Skip to content

thoughts on _getViewByModel #42

@robinplace

Description

@robinplace

Hey everyone,

I recently ran into a case where I needed to use a function similar to AmpersandCollectionView._getViewByModel. It seems to me that the need to do this would be frequent enough to warrant creating a public (non-underscore prefixed) method to allow fetching the view representing a given model.

What do you think about this?

In addition, it seems like the complexity of this method could be cut drastically by using a map (plain JS object) instead of an array to store in AmpersandCollectionView.views, with the key as the AmpersandState.cid and the value as the actual created view. Since the cid should be unique and never-changing, this should work great; and it would remove the need for a loop in the _getViewByModel method.

Again, what do the devs think about this.

The one concern I have is breaking backwards-compatibility with people using the views property. Is that a real concern?

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