Aron
Aron

Reputation: 1282

What is the best way to update elements into an observable array?

I see two options:

#1 observable_array.replace() ?

or

#2 observable_array=[ ] ?

Any suggestion will be appreciated?

Upvotes: 1

Views: 1645

Answers (1)

Christopher Chiche
Christopher Chiche

Reputation: 15345

You should favor the first according to the documentation

The problem with overriding the array is that you will lose the observable property if you don't override the observable array with a new observable array.

In the end, when setting an observable array, mobx observes changes for each entry of the array, not changes on the array object itself.

Upvotes: 1

Related Questions