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

Class Projection Notifications on sub objects #8276

Closed
alexjameslittle opened this issue Jun 15, 2023 · 3 comments
Closed

Class Projection Notifications on sub objects #8276

alexjameslittle opened this issue Jun 15, 2023 · 3 comments

Comments

@alexjameslittle
Copy link

alexjameslittle commented Jun 15, 2023

How frequently does the bug occur?

Always

Description

We are unable to observe a projection and successfully get it to fire when a deeply nested property changes. Is this expected behaviour?

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

Models:

class TestObject: Object {
    @Persisted(primaryKey: true) var id: String
    @Persisted var sub: TestSub?
}

class TestSub: Object {
    @Persisted var sub: TestSubSub?
}

class TestSubSub: Object {
    @Persisted var name: String = "test"
}

class TestProjection: Projection<TestObject> {
    @Projected(\TestObject.sub?.sub?.name) var name
}

Observer:

let token = await projection.observe(on: MainActor.shared) { _, _ in
            expectation.fulfill()
        }

Using the above objects and observation block, if you write to the "name" property, the observation on TestProjection is not notified.

Version

10.40.0

What Atlas Services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

iOS 16

Build environment

Xcode version: 14.3.1
Dependency manager and version: SPM

@dianaafanador3
Copy link
Contributor

Hi @alexjameslittle thanks for taking the time to open an issue. I tested your sample code and like you mentioned this doesn't seem to be working correctly. On the meantime I'll recommend using key paths for observing properties within a Projection that links to an object with nested properties. We'll take a look at the issue and let you know of any updates.

@dianaafanador3
Copy link
Contributor

dianaafanador3 commented Jul 17, 2023

Hi @alexjameslittle I was finally able to found the issue and I'm working on a PR which solves it #8298

@alexjameslittle
Copy link
Author

That's great news! Thanks @dianaafanador3

@sync-by-unito sync-by-unito bot closed this as completed Jul 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants