Giter Club home page Giter Club logo

Comments (6)

miguelcobain avatar miguelcobain commented on July 19, 2024

Thank you for the report.

Right now I'm a bit tight on time.
If you could provide me a jsbin of a scenario like this, I could definitely to take a look.

If you're wondering how to use ES6 classes on jsbin, just copy and paste the component code in a globals Component there. 😄

from ember-cli-selectize.

NotSqrt avatar NotSqrt commented on July 19, 2024

Here is a JSbin : http://emberjs.jsbin.com/hoqenocira/2/edit?html,js,output
(I had to add the ember-new-computed code)

It detects an infinite/too long loop, so I added // noprotect in selectionArrayWillChange.
I could not reproduce the really slow performance I observe in my app, so I might have other problems..

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 19, 2024

Seems pretty fast as well to me, but that might be because we're using fixtures here. I can also see that selectionArrayDidChange is running multiple times per route change.
I believe this is related with the selection=model.items.content part and thus related with #58. We should probably wait until the promise resolves to bind the observer.
Will do further investigation.

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 19, 2024

Here I test if selection is a promise, and only bind array observers when it is resolved:
http://emberjs.jsbin.com/rogenifopa/1/edit?html,js,console,output

Looks good. selectionArrayDidChange runs only once. Seems the way to go.

from ember-cli-selectize.

miguelcobain avatar miguelcobain commented on July 19, 2024

Edit: looks like that was already happening in your jsbin. My mistake.

Bottomline, your JSBin doesn't seem to have anything wrong with it and probably does not reproduce the problem in your app?

from ember-cli-selectize.

NotSqrt avatar NotSqrt commented on July 19, 2024

One of the main differences with my app is the use of templating (optionFunction, itemFunction).

I've done some profiling on my app.
Most of the time is spend in selectize, method updateOriginalInput, which keeps the original input up-to-date (which does not matter in ember-selectize).

Adding the following plugin to Selectize helps a lot (from 0.8s to 0.4s) :

Selectize.define('optimised', function(/*options*/) {
    // options: plugin-specific options
    // this: selectize instance
    var self = this;
    this.updateOriginalInput = (function() {
        var original = self.updateOriginalInput;
        return function(opts) {
            opts = opts || {};

            // constant in Selectize
            var TAG_SELECT    = 1;

            if (self.tagType === TAG_SELECT) {
                // copy the final action, bypasses a loop on all items and many HTML operations
                if (self.isSetup) {
                    if (!opts.silent) {
                        self.trigger('change', self.$input.val());
                    }
                }
            } else {
                // use the original full method
                original.apply(this, arguments);
            }
        };
    })();
});

After this change, most of the time is spent in the methods ObjectWasRemoved and selectionObjectWasAdded, and inside them, the time is spent in selectize setCaret and positionDropdown when removing the items, and in refreshOptions when adding items.

from ember-cli-selectize.

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.