0

I would like to know if this is extremely bad practice or not.

I am overriding arrangedContent and filtering the content when a user selects an item from a dropdown or types some text into an input so this function could run quite a lot:

I want to sort the results after I have filtered the results. I was thinking of doing this but thought against it:

arrangedContent: ( ->
  filtered = @get('content').filter (item) ->
    #filter content

  Ember.ArrayProxy.createWithMixins Ember.SortableMixin,
    sortProperties: ['name']
).property('model.[]', 'searchText')

I am curious to know what are the implications in terms of performance and potential memory leaks of doing something like this that could be ran every time a keystroke happens.

I used a normal sort on the content, but I am curious to know if this is really bad or not.

1
  • Honestly I think that having a create statement in a computed property is bad, because as you already said it would use a lot o unnecessary memory for new instances of the ArrayProxy. You should think of a possible arrayproxy that you reuse instead of creating new ones... Commented May 15, 2013 at 18:04

1 Answer 1

1

This is a bad practice that has caused me hours of pain on more occasions than I care to recall.

It is usually better to modify an array that is being observed instead of replacing it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.