Skip to content
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

ValueObservation Cleanup #488

Merged
merged 4 commits into from
Mar 1, 2019
Merged

ValueObservation Cleanup #488

merged 4 commits into from
Mar 1, 2019

Conversation

groue
Copy link
Owner

@groue groue commented Mar 1, 2019

This pull request fixes some issues with ValueObservation in GRDB3:

  • To guarantee asynchronous notifications (and never ever block your main thread), use the .async(onQueue:startImmediately:) scheduling:

    // On main queue
    var observation = ValueObservation.trackingAll(Player.all())
    observation.scheduling = .async(onQueue: .main, startImmediately: true)
    let observer = try observation.start(in: dbQueue) { (players: [Player]) in
        // On main queue
        print("fresh players: \(players)")s
    }
    // <- here "fresh players" is not printed yet.

    This scheduling used to be named .queue(_: startImmediately:) (a poor name which did not express the intent).

  • ValueObservation.extent has been removed. Now all observations last until the observer returned by the start method is deallocated.

@groue groue added this to the GRDB 4.0.0 milestone Mar 1, 2019
@groue groue force-pushed the feature/ValueObservationCleanup branch 3 times, most recently from 403c703 to 214992e Compare March 1, 2019 12:48
@groue groue marked this pull request as ready for review March 1, 2019 12:49
@groue groue mentioned this pull request Mar 1, 2019
26 tasks
@groue groue force-pushed the feature/ValueObservationCleanup branch from 214992e to 4ee2523 Compare March 1, 2019 12:51
@groue groue merged commit 661cca9 into GRDB-4.0 Mar 1, 2019
@groue groue deleted the feature/ValueObservationCleanup branch March 1, 2019 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant