Code Monkey home page Code Monkey logo

Comments (4)

groue avatar groue commented on June 2, 2024 1

The next version of the lib will not mention async sequences in the README of GRDBAsyncDemo.

Thank you for the report, @hjrnunes!

from grdb.swift.

groue avatar groue commented on June 2, 2024

Hello @hjrnunes,

Oh, I suppose you're surprised because there is no async sequence in GRDBAsyncDemo.

Thank you for reporting this: I'll update my wording, so that it is less misleading.

I did try to build a SwiftUI app from the ValueObservation.values(in:) async sequence.

Unfortunately, there is no way to tell Swift Concurrency to start an async sequence synchronously, which means that a SwiftUI view that feeds from an async sequence MUST display an empty state until the first value is produced. While some apps can live with this, some other apps can not. That's why the GRDBAsyncDemo demo is still Combine-based for the database observation feature. Combine has no problem starting a publisher synchronously, and is a better fit than Swift Concurrency for the most demanding UI applications.

If you really want to use an async sequence, there's no problem: start a Task, and iterate the values returned by ValueObservation.values(in:). There's no demo for that, but nothing prevents you from doing it. Your view will have to display an empty state, until the first value is produced by the Swift Concurrency runtime.

from grdb.swift.

hjrnunes avatar hjrnunes commented on June 2, 2024

Thanks @groue

from grdb.swift.

groue avatar groue commented on June 2, 2024

The doc was updated in the new version v6.27.0. Thanks again!

from grdb.swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.