Open
Description
add State.remap(Relation|Container) -> Relation|Container
role: given an object in the input state, get the corresponding one from the output state.
Goal: targeted comparison without the manual search
Right now if you want to check how a relation databag changes during event handling, you have to:
rel_in = Relation("foo")
state_in = State(relations=[rel_in, *<more relations>])
state_out = context.run(event, state_in)
rel_out = filter(lambda r: r.endpoint == rel_in.endpoint, state_out.relations)
That is, you're forced to manually search through all relations in order to find the corresponding one to the relation you've passed in the input state.
This is such a common use case that maybe having a uniform shortcut for 'give me the corresponding object in this state' could be a good API improvement.
This is low priority, syntactic sugar. First investigate how the users feel about it.