GithubHelp home page GithubHelp logo

Comments (9)

kamilogorek avatar kamilogorek commented on June 23, 2024

Not really, but you can easily do that on your own, here's the working PoC:

https://gist.github.com/kamilogorek/df66f02c452f67170062

from ampersand-collection.

dhritzkiv avatar dhritzkiv commented on June 23, 2024

Thanks!

On Jul 23, 2014, at 11:08 AM, Kamil Ogórek [email protected] wrote:

Not really, but you can easily do that on your own, here's the working PoC:

https://gist.github.com/kamilogorek/df66f02c452f67170062


Reply to this email directly or view it on GitHub.

from ampersand-collection.

wraithgar avatar wraithgar commented on June 23, 2024

this is almost exactly how we've solved this problem in the past, just remember to include add and remove events in your listenTo

from ampersand-collection.

HenrikJoreteg avatar HenrikJoreteg commented on June 23, 2024

We've talked about supporting this. Then you'd be able to directly listen to change:length for example. That seems to be the most common use case, but it's be cool to support this out of the box.

Trick is, with stuff like filtered sets is that it starts getting pretty inefficient as the collection size increases.

You might look at ampersand-sub-collection too. It's meant for this type of use, but has less docs/tests. it's simply not as polished.

from ampersand-collection.

HenrikJoreteg avatar HenrikJoreteg commented on June 23, 2024

going to close this for now, not sure we've got enough impetus to add this.

from ampersand-collection.

jrmyio avatar jrmyio commented on June 23, 2024

Currently facing a problem where I have a simple collection and I want to show the amount of items in the collection in the template. I cannot use bindings {} because the collection cannot have properties.

How would one solve this?

from ampersand-collection.

yallups avatar yallups commented on June 23, 2024

I think it would be cool of a collection inherited from state.

from ampersand-collection.

jrmyio avatar jrmyio commented on June 23, 2024

If there is not a simple solution for the collection/show length use case then I think something has to change. This could be limited to derived properties, but currently it seems you cannot have non-property dependencies for derived properties.

from ampersand-collection.

HenrikJoreteg avatar HenrikJoreteg commented on June 23, 2024

One potential approach.

initialize: function () {
  this.on('add remove reset', function () {
    this.trigger('change:length', this.length); 
  }, this);
}

Then from a view, you could bind it like:

bindings: {
   'collection.length': {
      selector: '.collection-length'
   }
}

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.