objectbox / objectbox/objectbox-swift
QueryPublisher unsubscribes after one event
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 619
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
Is there an existing issue?
- I have searched existing issues
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the QueryPublisher entry point and reproduce the issue with the provided Combine sink example. Check how the subscriber's Demand.none is handled after the initial query result. Done means the publisher remains subscribed and viewModel.persons continues updating when matching records are added or changed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- database, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100