CodeCoupler UI Async Contructor Pattern
This class is uesed internally. Normally you never have to use this.
Classes derived from here can initiated with
Or with:
Classes derived from here have to implement their asynchronous initialisation procedure within an method "init":
You can implement an additional method async prepare if you need to do things before init is
called. Depending on the return value the following action will be taken:
- If you return here
false,initwill not be executed. - If you return something different from
truethe theinitializedresolves to this returned value andinitwill not be executed. So aawait x = new Something().initializedwill result to this value as new instance.
Please keep in mind, that if you use a prepare method that could eventually return another
instance you should instruct the users to reassign the variable if not using the oneliner:
The first line would just return a new instatiated class, but the second line would return the instance you have specified with the method "prepare".