Skip to content

[Modular State Management] Share state/actions between iOS and macOS app? #48

@eivindml

Description

@eivindml

Hi everyone! 👋🏼

I'm working on a side projects where I'm using the architecture from the video series. Currently I've only worked on the iOS part of the app, and it works great.

I recently started on the macOS app as well, and would love some input/discussion how people would structure this.

Question

Would you write entirely new state and reducers for the new platform? Or extend/modify them so that we can share usage with the macOS target? Or other ideas?

The problem

The problem now is that each framework (for instance Counter from the episodes) has the state and reducers coupled with the Views (SwiftUI). And I'm not sharing much of the UI between the platforms. We could refactor this so that state/reducers are separate frameworks from the UI. Like Counter and CounterUI or something. Drawbacks is that we get double the amount if frameworks. Also we will often have state or actions that are only relevant for one of the platforms that will be visible for the other platforms. For instance action: addProjectModalModalDismissed and state isAddProjectModalShown which only is relevant for iOS.

Or we can write separate state and reducers for the macOS app. Like a CounterMacOS framework. Then we can have state/reducers and UI together, and we don't pollute the other platform with state/actions that aren't relevant, but obviously there are a lot of duplicated code to be written. For instance I have actions that load and save data to CloudKit, that obviously is used on both platforms.

Would love some input from anybody on this. What would you do, and why?

🦊💚

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions