Skip to content

More documentation around setting up a repo would be helpful #4

@oco-adam

Description

@oco-adam

Hi Andrew,

First of all, thanks very much for the great work so far on this project!


However, being fairly new to Core Data I’m not sure exactly how you intend to set up and use this repo in a way that doesn’t block the main queue, whilst not hitting thread exceptions due to Core Data accessing objects on different threads.

So a few lines in the Readme or an example of a project where you set up Core data with TCA so that it can be used in the background would be great.

To give you a bit more idea of my particular use case:

I’m trying to move migrate a project (which uses TCA) over from Realm to Core Data and I’m struggling to get Core data to work (partly due to my lack of knowledge and partly due to the additional quirks of Core Data regarding thread safety), so I’m hoping your project can sidestep the issues I’m coming across.

Currently I have a non standard Realm set-up i.e. I am using it as a repository in a similar vein to this project, rather than with “live objects”. In this way I can offload requests to the background - I.e. I can say things like this in my reducers:

         environment.database
          .doRepoAction()
          .subscribe(on: environment.backgroundQueue)
          .receive(on: environment.mainQueue)
		…

So ideally I would like an example where you set up your core data repo in a way that frees up the main thread and can ideally be used in situations such as the above. All your tests seem to use the viewContext rather than a background context, so I would like to understand:

When you use this package, do you still need to use things like container.newBackgroundContext() and context.perform { }, and if so, can you please give a simple example of how you might do this?

Many thanks,
Adam

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions