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

QueryPublisher unsubscribes after one event #86

Open
1 task done
Feuerwerk opened this issue Sep 18, 2024 · 1 comment
Open
1 task done

QueryPublisher unsubscribes after one event #86

Feuerwerk opened this issue Sep 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Feuerwerk
Copy link

Is there an existing issue?

Build info

  • ObjectBox version: 4.0.0

Steps to reproduce

let query: Query<Person> = ......
query.publisher
                    .replaceError(with: [])
                    /*.assign(to: \.persons, on: viewModel)*/
                    .sink(receiveValue: { persons in
                        viewModel.persons = persons
                    })
                    .store(in: &cancellables)

Expected behavior

I expected that viewModel.persons will update continuously when I add / change a record that will match my query.

Actual behavior

After the initial query result is consumed by the Subscriber, QueryPublisher will unsubscribe because various Subscriber implementations like sink(), assign(to:) or onReceive() of a SwiftUI view will return Subscriber.Demand.none which causes QueryPublisher to signal completion to the Subscriber and shut down.

@Feuerwerk Feuerwerk added the bug Something isn't working label Sep 18, 2024
@kemkriszt
Copy link

I'm also curious of how to handle this, I ended up creating a custom subscriber that after every receive requests unlimited but it seems like an ugly hack to me

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

No branches or pull requests

2 participants