Skip to content

Instantly share code, notes, and snippets.

@karthironald
Last active May 7, 2020 03:07
Show Gist options
  • Save karthironald/dba8813784a6aa818f680f1a4bc33de3 to your computer and use it in GitHub Desktop.
Save karthironald/dba8813784a6aa818f680f1a4bc33de3 to your computer and use it in GitHub Desktop.
final class MenuData: ObservableObject {
@Published var menu: [MenuSection] = [] // Will make an announcement when an item is added or remove from this menu array
}
struct ContentView: View {
@ObservedObject var menuData: MenuData = MenuData() // Listener added to receive data changed announcements to refresh the List inside body.
var body: some View {
List(menuData.menu) { menu in
Text(menu.name)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment