|
// don't peer review the style, I'm doing quick hacks :-) (I know it's not a valid argument) |
|
|
|
val ws:Widget = parts.map(_._2.widget).reduce((x:Widget, y:Widget) => x ++ y) |
|
|
|
import rx.lang.scala.{Observable => RxObservable, Observer => RxObserver, _} |
|
|
|
val mergedObservables:RxObservable[Seq[(String, Any)]] = { |
|
val l:List[RxObservable[(String, Any)]] = parts.map{ p => |
|
// widget has a dataConnection:Connection |
|
// Connection is a transient legacy crap that wraps a custom observer and a custom observable |
|
// A custom Observable... wraps a rx.Observable (or more precisely, its mirror in the Scala world) |
|
val ob = p._2.widget.currentData.observable.inner |
|
|
|
ob.subscribe(x => logInfo(x.toString)) //// ←←←←← this SH*T IS PRINTED :-/ |
|
|
|
val o:RxObservable[(String, Any)] = ob.map((d:Any) => (p._2.name, d)) |
|
o |
|
} |
|
// just a try in case Observable.from(l) wouldn't stop → hence zip won't start, because it needs to know N |
|
l.head.zip(l.tail.head).map(v => v._1 :: v._2 :: Nil) |
|
|
|
// is from not stopping? ↑↑↑ |
|
//RxObservable.zip(RxObservable.from(l)) |
|
} |
|
|
|
// Connection, okay → legay |
|
var sql:Connection[String] = Connection.just("") |
|
|
|
// ↓↓↓ None of these SH*T WILL BE PRINTED :'( |
|
mergedObservables.subscribe( |
|
onNext = (v:Seq[(String, Any)]) => { |
|
logInfo("============ssssss============") |
|
val values = v.toMap |
|
// okay, ignore the string building below, not interesting for the problem |
|
val s = parts.map { case (before, input) => |
|
val vv = values(input.name) |
|
before + vv.toString |
|
}.mkString(" ") |
|
logInfo(s) |
|
sql <-- Connection.just(s) // nah, fancy op to register the sql.observer to the observable of s :-/ |
|
}, |
|
|
|
onError = (t:Throwable) => logError("============ssssss============\n"+"Ouch in merged", t), |
|
|
|
onCompleted = () => logWarn("============ssssss============\n"+" Merged completed ! ") |
|
) |
The problem is you never subscribe to this. So nothing will happen.