-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add combine support (change listener) #1147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
SQLite is certainly capable of database observation. Check out GRDB's ValueObservation for ready-made Combine publishers. // Connect to the database
let dbQueue = ...
// Define an observation for the tracked value(s).
let observation = ValueObservation.tracking { db in
// Fetch anything you want, from as many tables as needed
return ...
}
// Turn the observation into a Combine publisher
let publisher = observation.publisher(in: dbQueue)
// Be notified of all changes, until the subscription is cancelled.
let cancellable = publisher.sink(
receiveCompletion: { completion in ... },
receiveValue: { value in
print("Fresh database value: \(value)")
}) |
@ursusursus Can you explain a bit more what you're after? |
@jberkel I basically want observable queries, that is to get the current result of the query as first emit, and then subsequent emits as the underlying data changes. In other words, query over time. |
Alright. See #686 for a related discussion, which unfortunately fizzled out (there was a user who mentioned opening a PR, but nothing materialized). |
Reactive database is needed in reactive architecture.
I don't see any Combine bindings provided. Is there some sort of data change listener I could adapt myself to Combine?
The text was updated successfully, but these errors were encountered: