Giter Site home page Giter Site logo

group-helper's Introduction

Ember.js group helper

This is an experimental plugin to allow an application developer to change the granularity of bindings in a template. This can lead to significant performance improvements when outputting many bound properties, inside of an #each for example.

The general rule is that the group helper causes the nearest view to be rerendered when a property inside it changes. It also prevents the common Handlebars helpers (#if, #unless, #each) from creating virtual views.

Currently requires Ember.js master.

Usage

  {{#group}}
    {{firstName}} {{lastName}}
  {{/group}}

Changes to firstName or lastName will rerender the whole group block.

  {{#group}}
    {{#each people}}
      {{firstName}} {{lastName}}
    {{/each}}
  {{/group}}

The whole group block will be rerendered upon addition/removal of elements in the people array or any properties output within the each block.

  {{#group}}
    {{#each people groupedRows=true}}
      {{firstName}} {{lastName}}
    {{/each}}
  {{/group}}

Specifying the groupedRows option will cause the #each to behave like a normal bound #each. There will be a virtual view for the each itself and for every row. Addition/removal of elements in the array will insert/remove rows in the DOM without causing the group to rerender. Since each row has a virtual view, changing a property output inside a row will only rerender that row.

  {{#group}}
    {{#each people itemViewClass="App.RowView"}}
      {{firstName}} {{lastName}}
    {{/each}}
  {{/group}}

You can alternatively specify an itemViewClass to get the behavior as detailed above, but instead of rows being virtual views, they'll be instances of your specified class.

group-helper's People

Contributors

ebryn avatar eviltrout avatar rwjblue avatar stefanpenner avatar tricknotes avatar wagenet 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

group-helper's Issues

itemController support

The group helper doesn't currently work with itemController's defined as arguments to the each helper. I'm working on a fix for this.

Block helper displays no data

I have the same issue as #3

No error is thrown but no data is output when wrapping {{#each}} in the group helper. My issue is that the table I'm building is very large but performance is pretty terrible. The table is static but I do need actions to work on the row so they are clickable.

    {{#group}}
        {{#each}}
            <tr {{action "getContext">
                <td>{{unbound name}}</td>
                <td>{{unbound time}}</td>
                <td>{{unbound count}}</td>
            </tr>
        {{/each}}
    {{/group}}

The only thing I see where there should be tr rows are a metamorph element:

<tbody>
<script id="metamorph-43-start" type="text/x-placeholder"></script>
<script id="metamorph-43-end" type="text/x-placeholder"></script>
</tbody>

I'm using the following versions of Ember:

DEBUG: ------------------------------- 
DEBUG: Ember      : 1.5.0 
DEBUG: Handlebars : 1.3.0 
DEBUG: jQuery     : 2.1.0 
DEBUG: ------------------------------- 

#group & #with not working together.

I noticed issues concerning use of {{#group}} & {{#with}} in EmberJS 1.0 & 1.3:

Consider template file element.handlebars:

{{#group}}
  {{#each item in items}}
    {{#with item}}
      {{#if item.containedInParent}}
        {{#unless item.showWithControls}}
          <li>
            {{partial 'element'}}
          </li>
        {{/unless}}
      {{/if}}
    {{/with}}
  {{/each}}
{{/group}}

This seems to work with only a single level of recursion, i.e. nested {{#each}} never get rendered.

On the other hand the following:

{{#each item in items}}
  {{#group}}
    {{#with item}}
      {{#if item.containedInParent}}
        {{#unless item.showWithControls}}
          <li>
            {{partial 'element'}}
          </li>
        {{/unless}}
      {{/if}}
    {{/with}}
  {{/group}}
{{/each}}

seems to generate infinite recursion (tested in Chrome & Firefox).

Besides group-helper, is there any other place in EmberJS that sets insideGroup to true? Is the code path where insideGroup is true tested in any way in EmberJS?

Should ember.js application developers use group-helper?

Hello

I have an ember app that renders a large nested list. It is pretty slow (10s on a 2010 MBPro). Reading this thread: http://discuss.emberjs.com/t/ember-is-very-slow-at-rendering-lists/1643 I decided to give the group-helper a shot. Looking at the code it seems that group-helper may not work with ember 1.8.1. Do I have to build ember along with group-helper to use it?

I cloned the repo and got this error when running bundle install:
fatal: repository 'https://github.com/emberjs/docs-generator.git/' not found

I removed the offending gem from the Gemfile and was able to build the project.

I'm concerned that the version of ember group-helper comes with is quite out of date (2012).

Do the authors of group-helper know of another helper, plugin, library that forces ember to not create virtual views & controllers for every element in a list/nested list built with {{each}} and {{view}}? Most of the nested elements in my app don't require data binding and would work well as simple tags.

Thanks!

distro for download or instructions for use

I'd love to try this out, but am somewhat intimidated by how to go about getting it into my project. My current guess (which I'm about to embark on trying) is to clone the repo, bundle and build the distribution js file.

I tried a (admittedly lazy) approach of just copying the body of packages/group-helper/lib/main.js into a helper in my app but that produced some weird results.

So this request is to provide a distribution and/or instructions for how to go about pulling this into a project.

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.