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

Update to Current Version of Composable Architecture (0.33.1) #2

Open
Mozahler opened this issue Feb 20, 2022 · 0 comments
Open

Update to Current Version of Composable Architecture (0.33.1) #2

Mozahler opened this issue Feb 20, 2022 · 0 comments

Comments

@Mozahler
Copy link

What a great job you've done! This is a really well thought-through project, and covers so much ground. So hats off!

I was able to update your project to use 0.33.1 instead of 0.15.0 with a very small change:

// url: "https://github.com/pointfreeco/swift-composable-architecture", .exact("0.15.0")),
url: "https://github.com/pointfreeco/swift-composable-architecture", from: "0.33.1"),

you could also substitute "0.9.0" here instead of "0.33.1" - it will use the highest version under 1.0 it finds

It looks like the definition of IdentifiedArray changed after 0.15.0 (I assume this is why you froze the project there).

There were only a few lines that needed to be changed - you just need to add id: as a label when updating an element of the identifiable array. You also need to adjust for optionality - hence the ?s. I marked the four affected lines below with ** delimiters

in Core/MinefieldCore.swift

public extension MinefieldState {
    mutating func reveal(_ index: Int) {
        self.reveal([index])
    }
    
    mutating func reveal(_ indexes: Set<Int>) {
        gridInfo.revealed.formUnion(indexes)
        gridInfo.flagged.subtract(indexes)
    ** indexes.forEach { grid.content[id: $0]?.isHidden = false }  **
    }
    
    mutating func setTile(_ newTile: Tile, for index: Int) {
       **grid.content[id: index]?.tile = newTile**
    }
    
    mutating func setMarked(_ isMarked: Bool, for index: Int) {
    ** grid.content[id: index]?.isMarked = isMarked  **
        if isMarked {
            gridInfo.flagged.insert(index)
        } else {
            gridInfo.flagged.remove(index)
        }
    }
    
    mutating func setWrongFlag(for index: Int) {
        var tileState = grid.content[index]
        tileState.isMarked = true
        tileState.tile = .mine
        tileState.isHidden = false
  **   grid.content[id: index] = tileState  **
    }
}

Thanks for providing this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant