Coder Social home page Coder Social logo

Comments (3)

stephencelis avatar stephencelis commented on July 24, 2024 1

UIScheduler is probably most helpful in SwiftUI when you don't want to be too fussy about controlling the scheduler in your environment, but want to still retain some testability for non-delayed effects, since immediately scheduled work will be performed in the test without the usual thread hop of receive(on: DispatchQueue.main).

Otherwise it's probably mostly useful in UIKit, where certain lifecycle events happen on the main thread and a further tick will cause layout glitches, like when a UITableViewCell is configured. In the end it should generally be useful in the same places that the ReactiveSwift scheduler is useful, but it's been awhile since I've lived in that pre-SwiftUI land, day-to-day 😅

from combine-schedulers.

stephencelis avatar stephencelis commented on July 24, 2024

The main reason we omitted the options here was because they don't seem to apply to the immediacy of a UI Scheduler.

I think generally you'd want to use AnySchedulerOf<UIScheduler> in your application if you want to override it with a TestScheduler in your tests.

I'm not even sure if there is any use case to actually replace UIScheduler with plain DispatchQueue. I was just used to writing this kind of API 😅

I think if you want to avoid an async "tick" when you are already processing things on the main thread, UIScheduler can still be important. A .receive(on: UIScheduler.shared) will not incur the cost of a thread hop, but .receive(on: DispatchQueue.main) will.

from combine-schedulers.

ollitapa avatar ollitapa commented on July 24, 2024

On the TCA front, would you recommend to use .receive(on: UIScheduler.shared) directly inside the reducer?

Or store it in the environment? So that there would be

struct Env {
  var workScheduler: AnySchedulerOf<DispatchQueue>
  var mainScheduler: AnySchedulerOf<UIScheduler>
}

And use pipe those like .subscribe(on: env.workScheduler).receive(on: env.mainScheduler)

from combine-schedulers.

Related Issues (17)

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.