DynamicData.Snippets icon indicating copy to clipboard operation
DynamicData.Snippets copied to clipboard

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

Open jocontacter opened this issue 4 years ago • 6 comments

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

jocontacter avatar Feb 22 '21 22:02 jocontacter

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

glennawatson avatar Feb 22 '21 23:02 glennawatson

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.

jocontacter avatar Feb 23 '21 07:02 jocontacter

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

glennawatson avatar Feb 23 '21 09:02 glennawatson

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

image this is not what i need

jocontacter avatar Feb 23 '21 13:02 jocontacter

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

glennawatson avatar Feb 23 '21 13:02 glennawatson

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

jocontacter avatar Feb 23 '21 14:02 jocontacter