def on_next(i): if type(i) is rs.OnNextMux: try: ii = mapper(i.item) observer.on_next(i._replace(item=ii)) except Exception as e: observer.on_next(rs.OnErrorMux(i.key, e, i.store)) else: observer.on_next(i)
def on_next(i): if type(i) is rs.OnNextMux: try: emit = predicate(i.item) if emit is True: observer.on_next(i) except Exception as e: observer.on_next(rs.OnErrorMux(i.key, e, i.store)) else: observer.on_next(i)
def on_next(i): if type(i) is rs.OnNextMux: try: if predicate(i.item) is True: observer.on_next(rs.OnNextMux(i.key, i.item)) else: observer.on_error( error("assert {} failed on: {}".format( name, i.item))) except Exception as e: observer.on_next(rs.OnErrorMux(i.key, e)) else: observer.on_next(i)
def on_next(i): nonlocal state if type(i) is rs.OnNextMux: try: value = i.store.get_state(state, i.key) if value is rs.state.markers.STATE_NOTSET: value = seed() if callable( seed) else copy.deepcopy(seed) acc = accumulator(value, i.item) i.store.set_state(state, i.key, acc) if reduce is False: observer.on_next(rs.OnNextMux(i.key, acc, i.store)) except Exception as e: observer.on_next(rs.OnErrorMux(i.key, e, i.store)) elif type(i) is rs.OnCreateMux: i.store.add_key(state, i.key) observer.on_next(i) elif type(i) is rs.OnCompletedMux: if reduce is True: value = i.store.get_state(state, i.key) if value is rs.state.markers.STATE_NOTSET: value = seed() if callable( seed) else copy.deepcopy(seed) observer.on_next(rs.OnNextMux(i.key, value, i.store)) observer.on_next(i) i.store.del_key(state, i.key) elif type(i) is rs.OnErrorMux: observer.on_next(i) i.store.del_key(state, i.key) elif type(i) is rs.state.ProbeStateTopology: state = i.topology.create_state(name='scan', data_type=type(seed)) observer.on_next(i) else: observer.on_next(i)
def on_error(e): observer.on_next(rs.OnErrorMux((0, ), e)) observer.on_error(e)