Skip to content

Conversation

@lawrence-forooghian
Copy link
Collaborator

Note: This PR is based on top of #19; please review that one first.

Some miscellaneous changes so that the upcoming OBJECT_SYNC spec implementation PR isn't too large. See commit messages for details.

The accompanying ably-cocoa change requires it.
Mark most of its types as Sendable, and callbacks as `sending`.

I was going to defer this until later but when I started writing
integration tests I realised that it's quite hard to actually use the
SDK without any sort of concurrency annotations (many basic things that
you try and do with it trigger a compiler error).

I haven't added annotations to the BatchContext things yet (because they
never leave the callback so may not need it); will address that once we
need to test those APIs.

Marking things as Sendable is consistent with the ably-cocoa public API,
which I think is going to the approach that we take threading-wise (but
will revisit in #3).
This was a mistake in ce8c022, in which I did not intend to add methods
that unsubscribe a given callback (since you can't compare closures by
reference in Swift). The equivalent functionality already exists via
OnLiveObjectLifecycleEventResponse.off().
I _think_ that there are enough times that you want to subscribe to
events without worrying about subsequently unsubscribing (in tests, but
I think also in real life, especially when just playing around with the
SDK) that we shouldn't make users think about the return value of these
methods.
I didn't copy the type across from JS correctly in ce8c022; their
LiveMapType is really just a dictionary with typed values.
When I copied the public API from JS in ce8c022 I didn't yet have enough
context to know how to translate the use of JS's `number` type. Now from
RTLc5 it's clear that counters are floating-point.
@github-actions github-actions bot temporarily deployed to staging/pull/20/AblyLiveObjects July 1, 2025 20:17 Inactive
For mocking in some upcoming tests. I've also decided to make the
internals of the SDK not need to worry about our current memory
management confusion, which will be revisited in #9.
Copy link
Collaborator

@umair-ably umair-ably left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool use of Swift 6 e.g. sending - not seen it in use before!

@lawrence-forooghian lawrence-forooghian merged commit 224c87b into main Jul 24, 2025
17 checks passed
@lawrence-forooghian lawrence-forooghian deleted the groundwork-for-object-sync branch July 24, 2025 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants