c# - Rx join over keys and not durations -
c# - Rx join over keys and not durations -
just looking rx bring together extension method. cant quite figure out how utilize create key bring together (using relational domain instead of time domain)?
var right = observable.range(4, 20); var left = observable.range(0, 30).where(n => n%2 == 0); var e = n1 in right bring together n2 in left on ? equals ? select new {n1, n2}; e.subscribe(j => console.writeline(" n1: {0}, n2: {1}", j.n1, j.n2)); desired output:
n1: 4, n2: 4 n2: 6, n2: 6 n3: 8, n2: 8 ... not sure if bring together can used way...?
edit
this works right way (concurrency, performance)?
var e = n1 in right n2 in left n1 == n2 select new { n1, n2 };
it of import maintain in mind observables collections on time - or way of putting series of events. enumerables can thought of collections @ moment in time.
it makes sense bring together on enumerables - of values available moment in time create join.
it's different when using rx - it's need sort of time travel!
so, whenever seek "join" in rx world saying "for period of time please remember of values on observable , match them values happen on observable b during period."
the join operator in rx used define custom periods of time , observe events occur within time periods.
the classic situation have stream of events whenever individual enters or exits room , want know in room when event (say lite turned on) occurs.
in ways sec query, selectmany query, bring together occurs on lifetime of 2 observables , rx had remember of values generate matches. pair of collections beingness built , performing joins values added.
the performance of selectmany long input sequences not big (which still may mean large, not large, ok) , terminate. using hot observables event patterns clicks bad selection selectmany against.
so, if have specific period of time bring together against - utilize join - if want bring together every value between 2 observables utilize selectmany.
c# system.reactive
Comments
Post a Comment