On the code below, I am trying to populate my listview with data coming from my EventStore.
So the func that I need information from this EventStore is "getEventsByType", but I am having the following error. Why ??
=======
struct EventListView: View {
var category = 1
@ObservedObject var store = EventStore().getEventsByType(typeId: 1, pageNumber:2)//// Type '()' cannot conform to 'ObservableObject'; only struct/enum/class types can conform to protocols
var body: some View {
List(store.events) { event in
NavigationLink(destination:
EventDetailView(event: event)
)
{
EventRow(evento event)
}
}
.navigationBarTitle(Text(category.name))
}
}
==============
THIS IS MY STORE
import SwiftUI
import Combine
class EventStore: ObservableObject {
@Published var events: [EventModel] =
init() {
}
func getEventsHome() {
EventsApi().getEventsHome() { (events) in
self.events = events
}
}
func getEventsByType(typeId: Int, pageNumber: Int) {
EventoApi().getEventsByType(typeId: typeId, pageNumber: pageNumber) { (events) in
self.events = events
}
}
Thank you,