@Target(value={METHOD,TYPE})
@Retention(value=RUNTIME)
public @interface Destroy
Marker annotation to identify a destroy method.
Only one (could be zero) destroy method is allowed in a particular class.
If a component is bound with a viewModel which has @Destroy methods,
The @Destroy method would be executed before the component detaching, or before the page or desktop which has this component being destroyed.
If it is triggered by detach, the @Destroy method can interact with UI,
but if it is triggered by destroying page or desktop, the @Destroy method won't interact with UI.
If you want binder to call super class's Destroy method also, you have to set superclass()
to true,
and super class's Destroy method will be called last.
You could annotate it on the type if the class doesn't has a Destroy method but super-class has.
For example, in class hierarchy A(has @Destroy) <- B(no @Destroy) <- C(has @Destroy, superclass true) <- D (has @Destroy, superclass false). D is the last one.
If A is the view model, will call A.Destroy only
If B is the view model, no method will be called
If C is the view model, will call C.Destroy
If D is the view model, will call D.Destroy then C.Destroy
Exception: if superclass()
was been set to true and your initial method
is an overridden method to it's super's initial method, ex:
X.m1() <- Y.m1()
Binder will throw an exception due to the conflict of java language's overriding nature.
@Destroy public void doDestroy()
Modifier and Type | Optional Element and Description |
---|---|
boolean |
superclass |
Copyright © 2005-2021 Potix Corporation. All Rights Reserved.