What is different between ObservableList and @observable List in MobX

166
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.

Share:
166
Mg Pin
Author by

Mg Pin

Updated on December 07, 2022

Comments

  • Mg Pin
    Mg Pin over 1 year

    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;