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

Fix isolation issue for shared state extension with key path #12

Merged
merged 1 commit into from
Jul 28, 2021

Conversation

lumiasaki
Copy link
Owner

@lumiasaki lumiasaki commented Jul 28, 2021

Delete SharedStateKey and SharedStateValues due to isolation issue. The previous implementation was based on single source of truth, but every variable was setting on or getting from SharedStateKey.currentValue, this might cause problems when you have more than one box and meanwhile you reuse the keys.

Modification is delete SharedStateKey and SharedStateValues completely, every shared state extension owns a separated stateValue, during its initialization phase developer needs to assign your instance of state to shared state extension. Developers do not need to extend SharedStateValues or define your SharedStateKey anymore, just provide an instance of your custom state value.

The rest part is still follow this PR, with same APIs, only one difference is you need to point out type for your key paths as below:

class ViewController: UIViewController, Scene {

    // \.timestamp -> \MyState.timestamp
    @SharedStateInjected(\MyState.timestamp)
    var timestamp: TimeInterval?
}

@lumiasaki lumiasaki added the bug Something isn't working label Jul 28, 2021
@lumiasaki lumiasaki merged commit 6586041 into main Jul 28, 2021
@lumiasaki lumiasaki deleted the fixbug/isolation_shared_state branch July 28, 2021 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant