its probably not pure right, I would use something...
# rx
u
its probably not pure right, I would use something with implicit "memory" like scan but it just doesnt work out, ill endup returning buffer from scan and then mapping to get the stuff from it, or returning a tuple of buffer and event, thats kind of silly
a
depends on scoping, if
buffer
lifetime is equal to the Observable, imo it's fine, but depends on your style
scan
would be more idiomatic yea
u
yes id like scan also so I dont need to sync the lifetime of the buffer as you said. but the actual usecase is explicit statemachine, which basically is fun
process(action): effect
, and from scan I'd need to return the statemachine instance. That would mean returning Pair<Statemachine, Effect> which at that point map is more idiomatic i think. I'd best want just to pass statemachine instance to next lambda, with action as input, effect as output.
maybe class StateMachineFunction : Function, and pass it to map directly instead of lambda and keep statemachine in its field? this would be scoped to observable right?
a
both ways should work if you have time — I'd recommend to try to make it work with scan, it's always a good exercise and you may end up liking the result
u
right, thx