RolandPheasant / DynamicData.Snippets

'101 samples' of dynamic data and rx in action
139 stars 13 forks source link

How to convert IObservable<IChangeSet<A,TKey>> to IObservable<IChangeSet<Tuple<A,A>,TKey>? #7

Open jocontacter opened 3 years ago

jocontacter commented 3 years ago

i need to pair up my original list like Observable<A>.Buffer(2).Select(list => Tuple.Create(list[0], list[1])) but there i have IChangeSet's which converts to Tuple<IChangeSet<A>,IChangeSet<A>> but not to IChangeSet<Tuple<A,A>> so i can't do .Bind(out pairs) on it

glennawatson commented 3 years ago

Don't use Select with DynamicData, use the Transform operator.

Also consider not using Tuple, try ValueTuple's and you can use the C# inbuilt way of using them (list[0], list[1]), ValueTuple have performance and memory advantages over Tuple's

jocontacter commented 3 years ago

Don't use Select with DynamicData, use the Transform operator.

Also consider not using Tuple, try ValueTuple's and you can use the C# inbuilt way of using them (list[0], list[1]), ValueTuple have performance and memory advantages over Tuple's

That is a problem - i can't do Transform() or Bind() on the result of Buffer() operator.

This is what i want to get: I have elements list: [a1,a2,a3,a4,...] which i want to convert to pairs -> (a1,a2),(a3,a4),(a5,a6)... How can i get a result like this?

Thanks for advice about ValueTuple.

glennawatson commented 3 years ago

You can do after you convert to a myObservable.ToObservableChangeSet()

jocontacter commented 3 years ago

You can do after you convert to a myObservable.ToObservableChangeSet()

image this is not what i need

glennawatson commented 3 years ago

Well that's useful information to know before you post since you only mention observable above

jocontacter commented 3 years ago

Sorry for misleading.. In short, i'm stuck at this place