Question: i`m using Vue and wanna use async/await to give a sequence for my function A and B

```
result is false by default    

mounted() {
  this.A();
  this.B();
}

async A() {
  this.result = await this.$api...
}

async B() {
  if(this.result) let data = await this.$another1 api...
  else let data = await this.$another2 api...
}

```

i assume that after function A call api and return a value of 'result' then, function B do his job.

However, sometimes api in function B called 'another2 api' before 'this.result' get his value even if result is 'true' after function A receive a value from $api

[![this is normal action which i expect](https://i.stack.imgur.com/3nIF3.png)](https://i.stack.imgur.com/3nIF3.png)

this is normal action which i expect

[![enter image description here](https://i.stack.imgur.com/6RLg3.png)](https://i.stack.imgur.com/6RLg3.png)

this is an error which was found sometimes when i refresh a page.

How can i solve this problem?

Answer: 
If you are coding in SwiftUI 2 you can convert your Color to UIColor and use getRed method to get the red, green, blue and alpha components. Once you have the components you can convert the values to hexa string:

---

```
extension Color {
    var uiColor: UIColor { .init(self) }
    typealias RGBA = (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)
    var rgba: RGBA? {
        var (r, g, b, a): RGBA = (0, 0, 0, 0)
        return uiColor.getRed(&r, green: &g, blue: &b, alpha: &a) ? (r, g, b, a) : nil
    }
    var hexaRGB: String? {
        guard let (red, green, blue, _) = rgba else { return nil }
        return String(format: "#%02x%02x%02x",
            Int(red * 255),
            Int(green * 255),
            Int(blue * 255))
    }
    var hexaRGBA: String? {
        guard let (red, green, blue, alpha) = rgba else { return nil }
        return String(format: "#%02x%02x%02x%02x",
            Int(red * 255),
            Int(green * 255),
            Int(blue * 255),
            Int(alpha * 255))
    }
}

```

---

```
Color.purple.hexaRGB     // "#af52de"
Color.purple.hexaRGBA    // "#af52deff"
if let (red, green, blue, alpha) = Color.purple.rgba {
    red   // 0.686274528503418
    green // 0.321568638086319
    blue  // 0.8705882430076599
    alpha // 1
}

```
Isn't it good to use it like this?

```
    import UIKit

extension UIColor {

    convenience init(hex:Int, alpha: CGFloat = 1.0) {
        self.init(
            red:   CGFloat((hex & 0xFF0000) >> 16) / 255.0,
            green: CGFloat((hex & 0x00FF00) >> 8)  / 255.0,
            blue:  CGFloat((hex & 0x0000FF) >> 0)  / 255.0,
            alpha: alpha
        )
    }

}

```