|
|
|
|
@ -9,22 +9,27 @@ import Foundation |
|
|
|
|
import LeStorage |
|
|
|
|
import SwiftUI |
|
|
|
|
|
|
|
|
|
class DataStore : ObservableObject { |
|
|
|
|
class DataStore: ObservableObject { |
|
|
|
|
|
|
|
|
|
// fileprivate var _store: Store |
|
|
|
|
|
|
|
|
|
@Published fileprivate(set) var tournaments: StoredCollection<Tournament> |
|
|
|
|
@Published fileprivate(set) var clubs: StoredCollection<Club> |
|
|
|
|
fileprivate(set) var tournaments: StoredCollection<Tournament> |
|
|
|
|
fileprivate(set) var clubs: StoredCollection<Club> |
|
|
|
|
|
|
|
|
|
init() { |
|
|
|
|
let store = Store.main |
|
|
|
|
store.synchronizationApiURL = "http://127.0.0.1:8000/api/" |
|
|
|
|
|
|
|
|
|
// let store = Store(synchronizationApiURL: "https://padelclub.app/api/") |
|
|
|
|
self.clubs = store.registerCollection(synchronized: true) |
|
|
|
|
self.tournaments = store.registerCollection(synchronized: false) |
|
|
|
|
|
|
|
|
|
// self._store = store |
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(collectionWasUpdated), name: NSNotification.Name.CollectionDidLoad, object: nil) |
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(collectionWasUpdated), name: NSNotification.Name.CollectionDidChange, object: nil) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@objc func collectionWasUpdated(notification: Notification) { |
|
|
|
|
self.objectWillChange.send() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|