GithubHelp home page GithubHelp logo

Comments (4)

wraithgar avatar wraithgar commented on July 3, 2024

No that is not intended, could you give an example of this?

from ampersand-collection.

lukekarrys avatar lukekarrys commented on July 3, 2024

If I'm reading this right, I think what you want is https://github.com/AmpersandJS/ampersand-filtered-subcollection

With ampersand-collection the behavior is this:

var Collection = require('ampersand-collection');
var C = Collection.extend({comparator: 'name'});
var c = new C([{name: 'z'}, {name: 'c'}, {name: 'b'}])

console.log(c.at(0).name, c.at(1).name, c.at(2).name);
// b c z

c.at(2).name = 'a';
console.log(c.at(0).name, c.at(1).name, c.at(2).name);
// b c a
// im assuming you want it to be `a b c`

from ampersand-collection.

wraithgar avatar wraithgar commented on July 3, 2024

Oh right, the collection has no way to know if attributes in an object change. So you either set the object wholly, or call sort, I think.

from ampersand-collection.

herkyl avatar herkyl commented on July 3, 2024

What if we listened to the change:comparator event when the comparator is a string. I think it would make sense for a collection with a comparator to keep itself sorted. If you'd like I can make a pull request.

Ampersand-filtered-subcollection is nice and I use it but I don't want to make a subcollection out of the entire collection for the sake of sorting. Right now I added a change listener to the collection and it works.

from ampersand-collection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.