kotlinx.rpc
 
0.5.1

Strict mode

Edit pageLast modified: 28 January 2025

Starting with version 0.5.0, the library introduces major changes to the service APIs. The following declarations will be gradually restricted:

  • StateFlow and SharedFlow

    Deprecation level: WARNING

    @Rpc
    interface Service : RemoteService {
        suspend fun old(): StateFlow<Int> // deprecated
    
        suspend fun new(): Flow<Int> // use .stateIn on the client side
    }
  • Fields

    Deprecation level: WARNING

    @Rpc
    interface Service : RemoteService {
        val old: Flow<Int> // deprecated
    
        suspend fun new(): Flow<Int> // store flow locally
    }
  • Nested Flows

    Deprecation level: WARNING

    @Rpc
    interface Service : RemoteService {
        suspend fun old(): Flow<Flow<Int>> // deprecated
    
        // no particular alternative, depends on the use case
    }
  • Not top-level server flows

    Deprecation level: WARNING

    data class SpotifyWrapped(val myMusicFlow: Flow<Rap>, val extra: Data)
    
    @Rpc
    interface Service : RemoteService {
        suspend fun old(): SpotifyWrapped // deprecated
    
        // one should consider message delivery order when calling these
        suspend fun new(): Flow<Rap>
        suspend fun getData(): Data
    }

Deprecation levels are controlled by the Gradle rpc extension:

Modes RpcStrictMode.NONE and RpcStrictMode.ERROR are available.