Is there any way to make assignAll to do not notify the listeners twice (once at clear and another time at addAll) ?
Is your feature request related to a problem? Please describe.
Every time I am trying to listen a RxList I have the problem that I receive 2 events every time I want to "replace" the list with a new one.
final RxList<String> myAwesomeList = RxList();
// onInit
myAwesomeList.listen( (newList) => print('new value : ${newValue.length}'));
// somewhere in the app
myAwesomeList.assignAll(['This', 'is', 'cool'];
// Once I call `assignAll` the `listen` will return this
// -> "new value : 0"
// -> "new value : 3"
// if I call it again
myAwesomeList.assignAll(['nothing'];
// -> "new value : 0"
// -> "new value : 1"
Describe the solution you'd like
I have tried to understand how the assignAll is working and after I have tried multiple solutions, seems like the only way is to change the set value from RxObjectMixin and force it somehow to not sentToStream in some specific situations. But also to be able to control the sentToStream from assignAll (or create replaceAll, probably someone really needs the current assignAll behaviour), because now sentToStream can be accessed from assignAll but it can't change the behaviour of set value.
Any better idea I can try ?
Temporary Workaround
// instead of `.listen` I use `debounce` worker
debounce<List<String>>( myAwesomeList, (newList) => print('debounce : ${newList.length}'));
// it works because the operations `clear` and `addAll` are quick and ignored by `debounce`, so it will return only the last value provided by `addAll`
Is there any way to make
assignAll
to do not notify the listeners twice (once atclear
and another time ataddAll
) ?Is your feature request related to a problem? Please describe. Every time I am trying to listen a
RxList
I have the problem that I receive 2 events every time I want to "replace" the list with a new one.Describe the solution you'd like I have tried to understand how the
assignAll
is working and after I have tried multiple solutions, seems like the only way is to change theset value
from RxObjectMixin and force it somehow to notsentToStream
in some specific situations. But also to be able to control thesentToStream
fromassignAll
(or createreplaceAll
, probably someone really needs the currentassignAll
behaviour), because nowsentToStream
can be accessed fromassignAll
but it can't change the behaviour ofset value
.Any better idea I can try ?
Temporary Workaround