IOS SDK - Artboard + trigger DataBind

Hello, I created an animation which makes use of the artboard databind to be able to select different artboards at runtime. I have a list of triggers which need to work in tandem with the artboard databind. That means if i want to trigger `peakIn` then an artboard needs to be also set.

I wrote this small VM to do that and it basically works fine but there is a small hickup.

/

class MyAnimationViewModel: ObservableObject {
    @Published private(set) var rive: Rive?

    /// Minimum interval between triggers in seconds.
    var triggerCooldown: TimeInterval = 3
    var lastAnimation: ReggieAnimationState = .initial

    private var lastTriggerDate: Date?

    @MainActor
    func load() async {
        self.rive = await RiveBuilder.shared.buildIfPossible(.reggieV3)
    }

    func trigger(_ state: ReggieAnimationState) {
        let now = Date()
        if let last = lastTriggerDate, now.timeIntervalSince(last) < triggerCooldown { return }
        lastTriggerDate = now

        // I wish I could know if an animation is still running before triggereing again
        guard let rive, let triggerName = state.trigger else { return }

        Task { @MainActor in
            do {
                let artboardProperty = ArtboardProperty(path: "artboard")
                let artboard = try await rive.file.createArtboard(state.artboardBinding)
                rive.viewModelInstance?.setValue(of: artboardProperty, to: artboard)
                // give some time for the artboard change to settle
                try? await  Task.sleep(nanoseconds: 100_000_000)
                let triggerProperty = TriggerProperty(path: triggerName)
                rive.viewModelInstance?.fire(trigger: triggerProperty)
            } catch {
                DebugViewLogger.shared.log("Failed to trigger ReggieAnimation: \(error)")
            }
        }
    }
}

Between setting the artboard and firing the trigger I need to add some time otherwise the trigger will never hit. Perhaps changing the artboard should be an await-able action so that I wouldn’t have the artificially wait for it.