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

[ECO-4936] Implement the ability to fetch a room #33

Merged
merged 3 commits into from
Sep 2, 2024

Conversation

lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented Aug 29, 2024

Part of #19. References to spec are based on ably/specification#200 at commit aa7455d.

The @preconcurrency imports of ably-cocoa are temporary and will be removed once ably/ably-cocoa#1962 is done; created #31 for tracking.

I’ve decided to, for now, throw ably-cocoa’s ARTErrorInfo for consistency with JS; created #32 to revisit this later.
https://ably.atlassian.net/browse/ECO-4936

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a structured error handling mechanism in the Ably Chat SDK for improved error reporting.
    • Added a new Room protocol and DefaultRoom class to manage chat room functionalities.
    • Enhanced Rooms protocol with a new implementation for better room instance management.
    • Added Equatable conformance to various room option structs for easier equality checks.
    • Implemented utility functions and tests to validate error handling and room management.
  • Bug Fixes

    • Improved error handling to ensure consistency in room options and error reporting.
  • Tests

    • Added unit tests for the DefaultRooms class to validate room retrieval and error handling.
    • Enhanced test framework with utility functions for better error assertions.

Copy link

coderabbitai bot commented Aug 29, 2024

Walkthrough

The changes introduce a structured error handling mechanism in the Ably Chat SDK, alongside a new protocol for room management. The implementation of the Room protocol and DefaultRoom class establishes a foundation for chat room functionalities. Enhancements to the Rooms protocol and the introduction of unit tests for the DefaultRooms class improve reliability. Utility functions and mock implementations support testing and error assertions.

Changes

Files Change Summary
Sources/AblyChat/Errors.swift Introduced error handling with errorDomain, ErrorCode enum, and ChatError enum for detailed error reporting. Added an extension for ARTErrorInfo to improve error creation and reporting.
Sources/AblyChat/Room.swift Defined Room protocol and DefaultRoom class with properties and asynchronous methods for managing chat rooms. Implemented basic structure for room functionalities, pending further development.
Sources/AblyChat/RoomOptions.swift Added Equatable conformance to RoomOptions, PresenceOptions, TypingOptions, RoomReactionsOptions, and OccupancyOptions structs for improved equality checks.
Sources/AblyChat/Rooms.swift Enhanced Rooms protocol with DefaultRooms class implementing thread-safe room management and retrieval logic. Added methods for creating and releasing rooms, with consistency checks on room options.
Tests/AblyChatTests/AblyChatTests.swift Modified test case to instantiate MockRealtime using a static method create() instead of a direct initializer.
Tests/AblyChatTests/DefaultRoomsTests.swift Introduced DefaultRoomsTests class with unit tests for DefaultRooms functionality, focusing on room retrieval, caching, and error handling for mismatched options.
Tests/AblyChatTests/Helpers/Helpers.swift Added assertIsChatError function for validating errors in tests, ensuring they conform to expected types and codes.
Tests/AblyChatTests/Mocks/MockRealtime.swift Introduced a static create() method in MockRealtime class for simplified instance creation without requiring a token.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DefaultRooms
    participant Storage
    participant DefaultRoom

    User->>DefaultRooms: get(roomID, options)
    DefaultRooms->>Storage: get(roomID, options)
    Storage->>DefaultRooms: return room or create new DefaultRoom
    DefaultRooms->>User: return DefaultRoom instance
Loading

🐰 In a world of chat, oh what a delight,
New errors and rooms, all shining so bright!
With options and tests, we hop and we play,
In the land of Ably, we chat every day!
So here’s to the changes, let’s cheer and rejoice,
For in this fine code, we all have a voice! 🐇✨

Assessment against linked issues

Objective Addressed Explanation
Establish a structured error handling
Implement room management functionality
Create unit tests for room management
Enhance usability of mock implementations

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lawrence-forooghian lawrence-forooghian marked this pull request as ready for review August 29, 2024 10:51
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bc06747 and 5a15ddc.

Files selected for processing (8)
  • Sources/AblyChat/Errors.swift (1 hunks)
  • Sources/AblyChat/Room.swift (2 hunks)
  • Sources/AblyChat/RoomOptions.swift (3 hunks)
  • Sources/AblyChat/Rooms.swift (1 hunks)
  • Tests/AblyChatTests/AblyChatTests.swift (1 hunks)
  • Tests/AblyChatTests/DefaultRoomsTests.swift (1 hunks)
  • Tests/AblyChatTests/Helpers/Helpers.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtime.swift (1 hunks)
Additional comments not posted (19)
Tests/AblyChatTests/AblyChatTests.swift (1)

6-6: LGTM!

The change to use MockRealtime.create() enhances the construction of MockRealtime, possibly indicating a more complex setup or configuration.

Tests/AblyChatTests/Helpers/Helpers.swift (1)

1-15: LGTM!

The helper function assertIsChatError is well-implemented and follows best practices for error assertions in unit tests.

Sources/AblyChat/RoomOptions.swift (5)

Line range hint 3-12: LGTM!

The addition of Equatable enhances the usability of the RoomOptions struct in contexts where equality checks are necessary.


Line range hint 17-25: LGTM!

The addition of Equatable enhances the usability of the PresenceOptions struct in contexts where equality checks are necessary.


27-33: LGTM!

The addition of Equatable enhances the usability of the TypingOptions struct in contexts where equality checks are necessary.


35-37: LGTM!

The addition of Equatable enhances the usability of the RoomReactionsOptions struct in contexts where equality checks are necessary.


39-41: LGTM!

The addition of Equatable enhances the usability of the OccupancyOptions struct in contexts where equality checks are necessary.

Tests/AblyChatTests/Mocks/MockRealtime.swift (1)

18-25: LGTM!

The create method is correctly implemented and enhances the usability of the MockRealtime class.

Sources/AblyChat/Room.swift (2)

1-1: LGTM!

The @preconcurrency import statement is correctly used to indicate that the imported module does not support concurrency.


Line range hint 2-18: LGTM!

The Room protocol is correctly defined and provides a clear contract for room implementations.

Sources/AblyChat/Rooms.swift (2)

1-1: LGTM!

The @preconcurrency import statement is correctly used to indicate that the imported module does not support concurrency.


2-8: LGTM!

The Rooms protocol is correctly defined and provides a clear contract for room implementations.

Tests/AblyChatTests/DefaultRoomsTests.swift (3)

6-21: LGTM!

The test function test_get_returnsRoomWithGivenID is well-written and covers the expected behavior.


24-38: LGTM!

The test function test_get_returnsExistingRoomWithGivenID is well-written and covers the expected behavior.


41-63: LGTM!

The test function test_get_throwsErrorWhenOptionsDoNotMatch is well-written and covers the expected behavior.

Sources/AblyChat/Errors.swift (4)

1-8: LGTM!

The error domain definition is correct and follows best practices.


10-26: LGTM! But revisit the TODO comment.

The ErrorCode enum is well-defined. However, the TODO comment indicates that the error code and status code are guesses and need to be revisited. Ensure that this is tracked and addressed in the future.


29-52: LGTM!

The ChatError enum is well-defined and provides useful metadata for the error.


54-67: LGTM! But revisit the TODO comment.

The extension for ARTErrorInfo is well-defined. However, the TODO comment indicates that the implementation needs to be revisited once the related issue in ably-cocoa is resolved. Ensure that this is tracked and addressed in the future.

Sources/AblyChat/Room.swift Outdated Show resolved Hide resolved
Sources/AblyChat/Rooms.swift Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5a15ddc and 6ab6ad3.

Files selected for processing (8)
  • Sources/AblyChat/Errors.swift (1 hunks)
  • Sources/AblyChat/Room.swift (2 hunks)
  • Sources/AblyChat/RoomOptions.swift (3 hunks)
  • Sources/AblyChat/Rooms.swift (1 hunks)
  • Tests/AblyChatTests/AblyChatTests.swift (1 hunks)
  • Tests/AblyChatTests/DefaultRoomsTests.swift (1 hunks)
  • Tests/AblyChatTests/Helpers/Helpers.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtime.swift (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • Sources/AblyChat/Errors.swift
  • Sources/AblyChat/Room.swift
  • Sources/AblyChat/RoomOptions.swift
  • Tests/AblyChatTests/DefaultRoomsTests.swift
  • Tests/AblyChatTests/Helpers/Helpers.swift
  • Tests/AblyChatTests/Mocks/MockRealtime.swift
Additional context used
Learnings (1)
Sources/AblyChat/Rooms.swift (1)
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#33
File: Sources/AblyChat/Rooms.swift:9-64
Timestamp: 2024-08-29T10:55:26.337Z
Learning: When reviewing code, do not ask lawrence-forooghian about "not yet implemented" `fatalError` calls.
Additional comments not posted (4)
Tests/AblyChatTests/AblyChatTests.swift (1)

6-6: LGTM! But verify the MockRealtime.create() method.

The change in the instantiation method for MockRealtime suggests an enhancement in the setup or configuration encapsulated within the create() method. Ensure that the create() method aligns with the intended behavior of the test.

The code changes are approved.

Run the following script to verify the MockRealtime.create() method:

Verification successful

Verification Successful: MockRealtime.create() Method Exists

The MockRealtime.create() method is correctly implemented in the Tests/AblyChatTests/Mocks/MockRealtime.swift file. It returns an instance of MockRealtime initialized with an empty key, which aligns with the intended behavior for testing. No further action is needed.

  • File: Tests/AblyChatTests/Mocks/MockRealtime.swift
  • Method: static func create() -> MockRealtime
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `MockRealtime.create()` method.

# Test: Search for the `create` method in the `MockRealtime` class. Expect: Correct implementation of the method.
rg --type swift -A 5 $'class MockRealtime {\n    static func create() -> MockRealtime'

Length of output: 395


Script:

#!/bin/bash
# Description: Verify the implementation of the `MockRealtime.create()` method.

# Test: Search for the `create` method in the `MockRealtime` class. Expect: Correct implementation of the method.
rg --type swift -A 5 $'class MockRealtime \\{\n    static func create() -> MockRealtime'

Length of output: 279


Script:

#!/bin/bash
# Description: Verify the implementation of the `MockRealtime.create()` method.

# Test: Search for the `create` method in the `MockRealtime` class. Expect: Correct implementation of the method.
rg --type swift --multiline -A 5 $'class MockRealtime \\{\n    static func create() -> MockRealtime'

Length of output: 99


Script:

#!/bin/bash
# Description: Search for the `MockRealtime` class and its static methods.

# Search for the `MockRealtime` class definition.
rg --type swift 'class MockRealtime' -A 10

# Search for static methods within the `MockRealtime` class.
rg --type swift 'static func' -A 3

Length of output: 3938

Sources/AblyChat/Rooms.swift (3)

2-7: LGTM!

The Rooms protocol defines the necessary methods and properties for room management.

The code changes are approved.


9-15: LGTM!

The DefaultRooms class is correctly implemented and conforms to the Rooms protocol.

The code changes are approved.


41-55: LGTM!

The get(roomID:options:) method correctly uses the Storage class to obtain a room and includes a validation step for room options.

The code changes are approved.

Sources/AblyChat/Rooms.swift Outdated Show resolved Hide resolved
Sources/AblyChat/Rooms.swift Show resolved Hide resolved
lawrence-forooghian added a commit that referenced this pull request Aug 29, 2024
Part of #19. References to spec are based on [1] at commit aa7455d.

I’ve decided to, for now, throw ably-cocoa’s ARTErrorInfo for
consistency with JS; created #32 to revisit this later.

We have decided (see [3]) that we’re going to try using actors as our
mechanism for concurrency-safe management of mutable state. We accept
that this will lead to more of the public API needing to be annotated as
`async` (as has happened to Rooms.get here), which in some cases might
lead to weird-looking API, and have chosen to accept this compromise in
order to get the safety checking offered to us by the compiler, and
because of developers’ aversion to writing "@unchecked Sendable". We
might not have needed to make this compromise if we had access to Swift
6 / iOS 18’s Mutex type, which allows for synchronous management of
mutable state in a way that the compiler is happy with. But, none of the
decisions here need to be final; we can see how we feel about the API as
it evolves and as our knowledge of the language grows.

[1] ably/specification#200
[2] ably/ably-cocoa#1962
[3] #33 (comment)
@lawrence-forooghian
Copy link
Collaborator Author

I’ve pushed a new commit (before the original one) that implements the DefaultChatClient.rooms property.

lawrence-forooghian added a commit that referenced this pull request Aug 29, 2024
Part of #19. References to spec are based on [1] at commit aa7455d.

I’ve decided to, for now, throw ably-cocoa’s ARTErrorInfo for
consistency with JS; created #32 to revisit this later.

We have decided (see [3]) that we’re going to try using actors as our
mechanism for concurrency-safe management of mutable state. We accept
that this will lead to more of the public API needing to be annotated as
`async` (as has happened to Rooms.get here), which in some cases might
lead to weird-looking API, and have chosen to accept this compromise in
order to get the safety checking offered to us by the compiler, and
because of developers’ aversion to writing "@unchecked Sendable". We
might not have needed to make this compromise if we had access to Swift
6 / iOS 18’s Mutex type, which allows for synchronous management of
mutable state in a way that the compiler is happy with. But, none of the
decisions here need to be final; we can see how we feel about the API as
it evolves and as our knowledge of the language grows.

[1] ably/specification#200
[2] ably/ably-cocoa#1962
[3] #33 (comment)
lawrence-forooghian added a commit that referenced this pull request Aug 29, 2024
Part of #19. References to spec are based on [1] at commit aa7455d.

I’ve decided to, for now, throw ably-cocoa’s ARTErrorInfo for
consistency with JS; created #32 to revisit this later.

We have decided (see [3]) that we’re going to try using actors as our
mechanism for concurrency-safe management of mutable state. We accept
that this will lead to more of the public API needing to be annotated as
`async` (as has happened to Rooms.get here), which in some cases might
lead to weird-looking API, and have chosen to accept this compromise in
order to get the safety checking offered to us by the compiler, and
because of developers’ aversion to writing "@unchecked Sendable". We
might not have needed to make this compromise if we had access to Swift
6 / iOS 18’s Mutex type, which allows for synchronous management of
mutable state in a way that the compiler is happy with. But, none of the
decisions here need to be final; we can see how we feel about the API as
it evolves and as our knowledge of the language grows.

[1] ably/specification#200
[2] ably/ably-cocoa#1962
[3] #33 (comment)
lawrence-forooghian added a commit that referenced this pull request Aug 29, 2024
Part of #19. References to spec are based on [1] at commit aa7455d.

I’ve decided to, for now, throw ably-cocoa’s ARTErrorInfo for
consistency with JS; created #32 to revisit this later.

We have decided (see [2]) that we’re going to try using actors as our
mechanism for concurrency-safe management of mutable state. We accept
that this will lead to more of the public API needing to be annotated as
`async` (as has happened to Rooms.get here), which in some cases might
lead to weird-looking API, and have chosen to accept this compromise in
order to get the safety checking offered to us by the compiler, and
because of developers’ aversion to writing "@unchecked Sendable". We
might not have needed to make this compromise if we had access to Swift
6 / iOS 18’s Mutex type, which allows for synchronous management of
mutable state in a way that the compiler is happy with. But, none of the
decisions here need to be final; we can see how we feel about the API as
it evolves and as our knowledge of the language grows.

[1] ably/specification#200
[2] #33 (comment)
This is preparation for storing a realtime client inside the Chat SDK’s
Sendable client types.

The Sendable requirement added here will be satisfied by ably-cocoa’s
ARTRealtime once [1] is resolved.

[1] ably/ably-cocoa#1962
Part of #19. References to spec are based on [1] at commit aa7455d.

I’ve decided to, for now, throw ably-cocoa’s ARTErrorInfo for
consistency with JS; created #32 to revisit this later.

We have decided (see [2]) that we’re going to try using actors as our
mechanism for concurrency-safe management of mutable state. We accept
that this will lead to more of the public API needing to be annotated as
`async` (as has happened to Rooms.get here), which in some cases might
lead to weird-looking API, and have chosen to accept this compromise in
order to get the safety checking offered to us by the compiler, and
because of developers’ aversion to writing "@unchecked Sendable". We
might not have needed to make this compromise if we had access to Swift
6 / iOS 18’s Mutex type, which allows for synchronous management of
mutable state in a way that the compiler is happy with. But, none of the
decisions here need to be final; we can see how we feel about the API as
it evolves and as our knowledge of the language grows.

[1] ably/specification#200
[2] #33 (comment)
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6ab6ad3 and 7d6acde.

Files selected for processing (11)
  • Example/AblyChatExample/ContentView.swift (1 hunks)
  • Example/AblyChatExample/Mocks/MockRealtime.swift (1 hunks)
  • Sources/AblyChat/ChatClient.swift (2 hunks)
  • Sources/AblyChat/Errors.swift (1 hunks)
  • Sources/AblyChat/Room.swift (2 hunks)
  • Sources/AblyChat/RoomOptions.swift (3 hunks)
  • Sources/AblyChat/Rooms.swift (1 hunks)
  • Tests/AblyChatTests/DefaultChatClientTests.swift (1 hunks)
  • Tests/AblyChatTests/DefaultRoomsTests.swift (1 hunks)
  • Tests/AblyChatTests/Helpers/Helpers.swift (1 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtime.swift (1 hunks)
Files skipped from review as they are similar to previous changes (6)
  • Sources/AblyChat/Errors.swift
  • Sources/AblyChat/Room.swift
  • Sources/AblyChat/RoomOptions.swift
  • Tests/AblyChatTests/DefaultRoomsTests.swift
  • Tests/AblyChatTests/Helpers/Helpers.swift
  • Tests/AblyChatTests/Mocks/MockRealtime.swift
Additional context used
Learnings (1)
Sources/AblyChat/Rooms.swift (3)
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#33
File: Sources/AblyChat/Rooms.swift:57-59
Timestamp: 2024-08-29T13:21:27.617Z
Learning: The user, lawrence-forooghian, prefers not to be warned about `fatalError` calls for missing implementations. This preference should be respected in future reviews.
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#33
File: Sources/AblyChat/Rooms.swift:9-64
Timestamp: 2024-08-29T10:55:26.337Z
Learning: When reviewing code, do not ask lawrence-forooghian about "not yet implemented" `fatalError` calls.
Learnt from: lawrence-forooghian
PR: ably-labs/ably-chat-swift#9
File: Sources/AblyChat/RoomStatus.swift:3-33
Timestamp: 2024-08-28T13:01:11.701Z
Learning: When reviewing code, avoid commenting on TODOs that already have a linked GitHub issue, as per the user's preference.
Additional comments not posted (15)
Example/AblyChatExample/ContentView.swift (1)

7-7: LGTM!

Using a factory method MockRealtime.create() improves encapsulation and maintainability.

The code changes are approved.

Tests/AblyChatTests/DefaultChatClientTests.swift (2)

5-12: LGTM!

The test correctly verifies that DefaultChatClient uses default client options when clientOptions is nil.

The code changes are approved.


14-26: LGTM!

The test correctly verifies that the rooms property of DefaultChatClient returns an instance of DefaultRooms with the same realtime client and clientOptions.

The code changes are approved.

Sources/AblyChat/Rooms.swift (5)

4-4: LGTM!

Updating the get(roomID:options:) method to be asynchronous aligns with modern concurrency practices in Swift.

The code changes are approved.


9-20: LGTM!

The DefaultRooms class is correctly implemented and adheres to the Rooms protocol.

The code changes are approved.


22-37: LGTM!

The get(roomID:options:) method is correctly implemented and ensures consistency in room management.

The code changes are approved.


39-41: Skipping comment on unimplemented method.

The user prefers not to be warned about fatalError calls for missing implementations.


12-12: LGTM!

The clientOptions property is correctly implemented and provides necessary access to client configuration options.

The code changes are approved.

Example/AblyChatExample/Mocks/MockRealtime.swift (3)

4-4: LGTM!

Marking the class as final and conforming to Sendable is appropriate for a mock class.


9-11: LGTM!

Triggering a fatalError for unimplemented properties in a mock class is appropriate.


19-26: LGTM!

The create() method provides a convenient way to create an instance without needing to provide a valid API key, which aligns with the current limitations of the example app.

Sources/AblyChat/ChatClient.swift (4)

7-7: LGTM!

Changing the realtime property type to RealtimeClient enhances type safety and clarity regarding the expected capabilities of the property.


11-11: LGTM!

The typealias RealtimeClient combines ARTRealtimeProtocol and Sendable, which is appropriate for the realtime property.


13-28: LGTM!

Transforming the class into an actor supports concurrency with isolated state management. The updates to the properties ensure proper initialization and nonisolated access where necessary.


42-45: LGTM!

The isEqualForTestPurposes method provides a way to compare instances for testing without requiring the struct to conform to Equatable.

@lawrence-forooghian
Copy link
Collaborator Author

I’ve pushed another commit to require that the realtime client conform to Sendable; this removes the need to scatter @preconcurrency import Ably across the codebase, moving that need to only the place where you initialise the library, which is clearer, I think.

@lawrence-forooghian lawrence-forooghian changed the title Implement the ability to fetch a room [ECO-4936] Implement the ability to fetch a room Aug 29, 2024
Copy link
Collaborator

@maratal maratal left a comment

Choose a reason for hiding this comment

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

LGTM

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.

🚀

@lawrence-forooghian lawrence-forooghian merged commit 0e9f703 into main Sep 2, 2024
17 checks passed
@lawrence-forooghian lawrence-forooghian deleted the 19-fetch-room branch September 2, 2024 12:11
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