ably / ably-asset-tracking-swift

iOS client SDKs for the Ably Asset Tracking service.
Apache License 2.0
9 stars 6 forks source link

Make `TrackableState` consistent with Android #625

Open lawrence-forooghian opened 1 year ago

lawrence-forooghian commented 1 year ago

As of https://github.com/ably/ably-asset-tracking-swift/issues/624, Swift’s TrackableState looks like this:

/**
 Indicates Asset connection status (i.e. if courier is publishing their location)
 */
public enum TrackableState: Int {
    /**
     Asset is connected to tracking system and we're receiving their position
     */
    case online

    /**
     Asset is not connected
     */
    case offline

    /**
     Connection has failed
     */
    case failed
}

but in Android at 4d13ae7 it looks like this:

/**
 * Represents a state of a trackable that's being tracked by a publisher.
 */
sealed class TrackableState {
    /**
     * Trackable state is [Online] when it's being actively tracked.
     * This state can change to either [Offline] or [Failed].
     */
    object Online : TrackableState()

    /**
     * Trackable state is [Publishing] when its locations are being published but it is not able to detect subscribers or receive data from them.
     * This state allows the trackable to be actively tracked, however, its features are limited compared to the [Online] state.
     * This state can change to either [Online] or [Offline] or [Failed].
     */
    object Publishing : TrackableState()

    /**
     * Trackable state is [Offline] when it's connecting or recovering from an error and hopefully will soon be back in the [Online] or [Publishing].
     * This state can change to either [Online] or [Publishing] or [Failed].
     */
    data class Offline(val errorInformation: ErrorInformation? = null) : TrackableState()

    /**
     * Trackable state is [Failed] when there was an error from which we cannot recover.
     * This is a final state.
     */
    data class Failed(val errorInformation: ErrorInformation) : TrackableState()
}

That is, there is an extra state Publishing, and the Offline and Failed states can communicate error information (which presumably on Swift is instead communicated using the publisher and subscribers’ delegate methods).

We should make Swift consistent with Android here, including the communication of error information.

sync-by-unito[bot] commented 1 year ago

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3468