Giter Site home page Giter Site logo

backbone.subset's People

Contributors

garbelini avatar latentflip avatar masylum avatar saimonmoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backbone.subset's Issues

Backbone.Subset does not correctly extend Backbone.Collection

If you create a new instance of a Backbone.Subset, it does not act as an instance of a Backbone.Collection:

!(mySubset instanceof Backbone.Collection) === true

This is a problem because it means you can't always substitute a Subset for a Collection. Knockback, for instance, can't make a collectionObservable around a Subset because it does an instanceof safety check.

parent() called in constructor, but impossible to set from constructor

As seen here: https://github.com/masylum/Backbone.Subset/blob/master/backbone.subset.js#L23-26

Backbone.Subset = function Subset(models, options) {
    options = options || {};

    this.model = this.parent().model;

The trouble with this is it effectively turns instances of Backbone.Subset into singletons, you have to define:

SomeSubset.prototype.parent = function() { /*....*/ }

In such a way that it is very aware of the program implemented around it.

The data inside the instances of a class ought to be passed into the constructor, not the implementation of the class itself.

recalculate bug?

In the reduce function of Subset.recalculate, short-circuit evaluation is causing the right side of:

return changed || self._updateModelMembership(model, {silent: true})

to never be eval'd once changed becomes true. This causes sieve to not be called on each element.

Most likely want:

return self._updateModelMembership(model, {silent: true}) || changed;

`_reset` is called before Collection Constructor

It may be a documentation issue, or it may be a bug, I can't tell.

Line 59 results in an error because this.models (usually set in the Backbone.Collection constructor) hasn't been set yet. I'm not 100% sure what solution to suggest (thus why it's not a pull request) since I'm not really sure if it's a bug or documentation issue. Either way it's worth fixing because this is a very handy, well written tool.

Steps to Reproduce:

coll = new Backbone.Collection([], {})
new Backbone.Subset([], {parent: coll, sieve: function(m) { return true; }})

This happens whether or not you pass in the undocumented no_reset option. If no_reset is true the error fires at line 152

_byCid and inheritance

It appears this repo has gone dormant. I've been using this plugin for awhile, and fixed a couple bugs.

  1. Since _byCid was deprecated, the _updateModelMembership function broke. This has been fixed.

  2. When extending from a parent collection, the subset was not inheriting any extra properties that may have been set on it. This has also bee fixed.

Fork is here: https://github.com/sarink/Backbone.Subset - I will try to keep updating Pau's code as necessary because I still like this little subset library!

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.