Created
February 23, 2023 09:09
-
-
Save Dimillian/fb0c282b055297ddee979322b1acbdd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Combine | |
struct ContentView: View { | |
@State var items: [Int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
var body: some View { | |
List { | |
ForEach(items, id: \.self) { item in | |
Text("Item: \(item)") | |
} | |
} | |
.onReceive(Timer.publish(every: 0.8, on: .main, in: .common).autoconnect()) { _ in | |
withAnimation { | |
items.insert(Int.random(in: Int.min..<Int.max), at: 0) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment