@SuppressWarnings({ "rawtypes", "unchecked" }) public Flowable<EntityStateMachine<?, Id>> flowable() { return Flowable.defer(() -> { Worker worker = signalScheduler.createWorker(); Flowable<Signal<?, Id>> o0 = subject // .toSerialized() // .toFlowable(BackpressureStrategy.BUFFER) // .mergeWith(signals) // .doOnCancel(() -> worker.dispose()) // .compose(preGroupBy); Flowable<GroupedFlowable<ClassId<?, Id>, Signal<?, Id>>> o; if (mapFactory != null) { o = o0.groupBy(signal -> new ClassId(signal.cls(), signal.id()), x -> x, true, 16, mapFactory); } else { o = o0.groupBy(signal -> new ClassId(signal.cls(), signal.id()), Functions.identity()); } return o.flatMap(g -> { Flowable<EntityStateMachine<?, Id>> obs = g // .flatMap(processSignalsToSelfAndSendSignalsToOthers(worker, g.getKey())) // .doOnNext(m -> stateMachines.put(g.getKey(), m)) // .subscribeOn(processingScheduler); // Flowable<EntityStateMachine<?, Id>> res = entityTransform .apply(grouped(g.getKey(), obs)); return res; }); }); }
@SuppressWarnings({ "rawtypes", "unchecked" }) public Flowable<EntityStateMachine<?, Id>> flowable() { return Flowable.defer(() -> { Worker worker = signalScheduler.createWorker(); Flowable<Signal<?, Id>> o0 = subject // .toSerialized() // .toFlowable(BackpressureStrategy.BUFFER) // .mergeWith(signals) // .doOnCancel(() -> worker.dispose()) // .compose(preGroupBy); Flowable<GroupedFlowable<ClassId<?, Id>, Signal<?, Id>>> o; if (mapFactory != null) { o = o0.groupBy(signal -> new ClassId(signal.cls(), signal.id()), x -> x, true, 16, mapFactory); } else { o = o0.groupBy(signal -> new ClassId(signal.cls(), signal.id()), Functions.identity()); } return o.flatMap(g -> { Flowable<EntityStateMachine<?, Id>> obs = g // .flatMap(processSignalsToSelfAndSendSignalsToOthers(worker, g.getKey())) // .doOnNext(m -> stateMachines.put(g.getKey(), m)) // .subscribeOn(processingScheduler); // Flowable<EntityStateMachine<?, Id>> res = entityTransform .apply(grouped(g.getKey(), obs)); return res; }); }); }