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

Correct way to update MutableObservableArray2D from signals #692

Open
yhdzhang opened this issue Oct 23, 2020 · 0 comments
Open

Correct way to update MutableObservableArray2D from signals #692

yhdzhang opened this issue Oct 23, 2020 · 0 comments

Comments

@yhdzhang
Copy link

Hi all,

I have declared a MutableObservableArray2D as a property in my class which is used as a CollectionView data source. I have multiple signals which generate section data for my CollectionView data source. What is the correct way to update MutableObservableArray2D ?
I have been doing it like below in my project, but i'm starting to have weird timing issues.

let sections = MutableObservableArray2D(Array2D<String, String>(sectionsWithItems: [
    ("foo", []),
    ("bar", []),
]))

func start() {
    SafeSignal<String>(just: "foo").observeNext { string in
        self.sections.replaceItems(ofSectionAt: 0, with: [string], performDiff: false)
    }
    .dispose(in: bag)

    SafeSignal<String>(just: "bar").observeNext { string in
        self.sections.replaceItems(ofSectionAt: 1, with: [string], performDiff: false)
    }
    .dispose(in: bag)
}
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