Skip to content

Migration Guide

Joan Pablo edited this page Jul 22, 2020 · 15 revisions

Migrate from 1.x to 2.x

Events renamed:

  • In AbstractControl

    • onValueChanged to valueChanges
    • onStatusChanged to statusChanges
    • onTouched to touchChanges
  • In FormGroup and FormArray

    • onCollectionChanged to collectionChanges
  • In FormControl

    • onFocusChanged to focusChanges

All events are now Streams so the following code:

final control = FormControl<String>();

control.onValueChanged.addListener((){
  print(control.value);
});

control.value = 'Hello Reactive Forms!';

converts to:

final control = FormControl<String>();

control.valueChanges.listen((String value){
  print(value);
});

control.value = 'Hello Reactive Forms!';
Clone this wiki locally