What is different between ObservableList and @observable List in MobX

Viewed 254

I'm a Noob. As the title say What the difference between these three

ObservableList<Todo> todos;

@observable
ObservableList<Todo> todos;

@observable
List<Todo> todos;
2 Answers
ObservableList<Todo> todos;

This will activate observable only when modifying list, not assigning new one.

@observable
ObservableList<Todo> todos;

This means that both assigning new list to todos or modifying todos list would activate observable.

@observable
List<Todo> todos;

This means that observable will be activated every time you make new assignment to todos field. Modifying todo list will not activate observable.

The list will not notify Mobx that a value has changed when you do:

listOfMatches[0] = match;

But both will work when you do:

listOfMatched = []
Related