Carlton Whitehead

02/11/2020, 3:22 PM
Is there a way, short of creating a new
, to obtain a new instance of a
each time? I'm finding it a bit clunky and error-prone to build out the
such that it expects a
with its dependencies graph prepared. Making the `Wizard`'s
know about all the wizard pages dependencies, those pages dependencies' dependencies, and so on is what makes it feel clunky to me. Is there a way
could act as a factory instead of as a singleton lookup? I feel like that would really simplify this. Is that possible?
The subtext of this is that I want a completely fresh wizard each time. Using
results in getting the same wizard each time, with old values left-over from prior use.


02/12/2020, 12:08 AM
without just looking at the code, it seems you wan tthe wizard to behave as a fragment. One thing that is possible is to just remove the reference to the current wizard from the scope, but that may cause a memory leak. Something like FX.getComponents().remove(Wizard::class)

Carlton Whitehead

02/12/2020, 12:10 AM
Thats pretty much the issue... Wizard extends View. But it's not just the wizard, it's all the steps and their viewmodels, etc too. Removing the reference to the wizard would still leave all the steps, etc. Still kind of messy
I think a
might be the answer. Inside the wizard could use that to make sure its dependences don't linger in the scope, without having to go to the trouble of setting up or tearing down a new scope.
I wonder if it would make more sense to instantiate it directly, if the point is to make the call site own the instance
I should have known better than to do that. Instantiating views directly misses out on all the extra bits the framework gives you when using its injection mechanics. So maybe a
method is warranted after all. I'm going to experiment with that offline some and will file a ticket if it seems to pan out.