Hello. Im playing with StateFlow to implement a kind of 'Live Card' that displays properties of simple or complex objects.
For the Complex case -- the 'objects' are really an abstraction layer around multiple API's that can be used to query the 'object state'
For example a "PrintJob" has a Workflow, File List, JobSpec, possibly multiple long running tasks (spanning days and multiple systems) As well
as a number of 'related' objects which themselves are either simple or complex, and often form a reference cycle. (Job -> Contains File -> Owned By Job )
Im considering modeling each 'group' of properties that are physically associated as implementing one 'StateFlow<MyClass>' -- > one 'state' value being the whole object - (set of properties),
and then for complex objects exposing an interface with man StateFlow properties.
The result would be a graph of StateFlow
Consumers could then collect from any point in the graph for the properties they were interested --
Does this make any sense ?
The problem Im considering is how to manage 'equality' such that the collection of StateFlow properly trigger a change when contained StateFlow's do.
How do I trigger a change to propagate to containing StateFlows ?
This might be the same question as how to indicate changes if 'value' is a any container (collection or object) --
I belive I have to update the value property itself to get the MutableStateFlow to emit --
In a graph of StateFlow would i have to walk the entire graph and re-assign (back to itself) all the 'value' properties of each MutableStateFlow to get invoke all the active 'collect' coroutines ?
E.g suppose 1 field in JobSpec changed, and that JobSpec was refrerend by a PrintJob -- (both StateFlow). I would need to update the 'value' property of both the JobSpec and PrintJob MutableStateFlow objects ?
An alternative model Im considering is to create the StateFlow on demand not as a static part of the model.
e.g a function like 'asStateFlow()' which creates a new MutableStateFlow(object) every call -- vs pre-creating and sharing the same flow.