mobxjs / mobx.dart

MobX for the Dart language. Hassle-free, reactive state-management for your Dart and Flutter apps.
https://mobx.netlify.app
MIT License
2.39k stars 311 forks source link

Issue In ObservableList while using addAll method with iterables. #941

Closed ParthBaraiya closed 10 months ago

ParthBaraiya commented 11 months ago

Hello,

When I add elements in ObservableList using addAll method and Iterable, It executes the iterables twice. I'm sharing a code snippet that will help to understand the issue.

final list = ObservableList<String>.of([]);

void addItems() {
    list.addAll([1,2,3,4].map((e) {
        print('$e');
        return '$e';
    }));
}

/// calling addItems method will Print
/// 1
/// 2
/// 3
/// 4
/// 1
/// 2
/// 3
/// 4

/// but expected output is,
/// 1
/// 2
/// 3
/// 4