- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 61
 
Update time travel documentation to describe the feature in more detail #297
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
Conversation
        
          
                docs/time_travel.md
              
                Outdated
          
        
      | 
               | 
          ||
| ### TimeTravelServer | ||
| 
               | 
          ||
| If using the time travel plugin or desktop app for debugging described later in this document, then the `TimeTravelServer` needs to be running on the Android or iOS application. The default port of the `TimeTravelServer` is 6379 unless explicitly changed in the application setup. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily Android or iOS, the TimeTravelServer currently supports android, jvm and all Darwin targets. Maybe write it somehow differently? E.g. "needs to be running on an application being debugged" or something like that?
| 
               | 
          ||
| If using the time travel plugin or desktop app for debugging described later in this document, then the `TimeTravelServer` needs to be running on the Android or iOS application. The default port of the `TimeTravelServer` is 6379 unless explicitly changed in the application setup. | ||
| 
               | 
          ||
| #### Setup TimeTravelServer Android | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to also add a section for normal JVM app setup. There is no any sample available, as far as I know. But it is very similar to Android, except the TimeTravelServer should be started somewhere in fun main(). A closest sample can be found in the JB TodoApp. So basically same approach, just create the TimeTravelServer if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something I am missing in trying to add the TimeTravelServer to the todo app? I cannot seem to get the desktop time travel app to connect with the todo app 🤔   commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you basically didn't implement the runOnMainThread function. It can be implemented using SwingUtilities.invokeLater, or using coroutines if they are used in the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I was thrown off by that function because I don't remember needing to implement that for the other platforms. I could get it working though, what is that used for exactly?
    val timeTravelServer = TimeTravelServer(runOnMainThread = {
        SwingUtilities.invokeLater(it)
    })
    timeTravelServer.start()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android has Handler, for Darwin targets there is dispatch_get_main_queue. But there nothing like this for the pure JVM target, it depends on the framework used by the client. So at the moment we have to provide it via DI.
        
          
                docs/time_travel.md
              
                Outdated
          
        
      | 
               | 
          ||
| > ⚠️ Since the `TimeTravelServer` does use the internet on the device for communicating with the development machine, even if the app does not use the internet you will need to declare the uses internet permission in the [AndroidManifest.xml](https://github.com/arkivanov/MVIKotlin/blob/master/sample/todo-app-android/src/main/AndroidManifest.xml#L6). | ||
| #### Setup TimeTravelServer iOS | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not only iOS. Maybe "Darwin" or "Apple"?
        
          
                docs/time_travel.md
              
                Outdated
          
        
      | #### Setup TimeTravelServer iOS | ||
| 
               | 
          ||
| To setup the `TimeTravelServer` on iOS, the `mvikotlin-timetravel` dependency must be exported into the shared module from the [`build.gradle.kts`](https://github.com/arkivanov/MVIKotlin/blob/4e0624946fe24a2fc47ecbfeb35a6fecaf09f709/sample/todo-darwin-umbrella/build.gradle.kts#L27). Replace `<version>` with the latest [release version](https://github.com/arkivanov/MVIKotlin/releases). | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth to mention that the dependency should be also added as api.
        
          
                docs/time_travel.md
              
                Outdated
          
        
      | 
               | 
          ||
| #### How to connect to an iOS device | ||
| 
               | 
          ||
| To connect the time travel client to an iOS emulator, open up the time travel client settings. Make sure the "Connect via ADB" is unchecked and host is `localhost`. Save the settings and link to the device to start recording. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is "simulator" AFAIK, not "emulator".
e6f7d9f    to
    76d6aaa      
    Compare
  
    76d6aaa    to
    b83e72b      
    Compare
  
    | #### Setup TimeTravelServer JVM | ||
| 
               | 
          ||
| First import the time travel dependency in the application module. Replace `<version>` with the latest [release version](https://github.com/arkivanov/MVIKotlin/releases). | ||
| 
               | 
          ||
| ```kotlin | ||
| implementation("com.arkivanov.mvikotlin:mvikotlin-timetravel:<version>") | ||
| ``` | ||
| 
               | 
          ||
| In the main function of the application, create an instance of the `TimeTravelServer` and implement the `runOnMainThread` property. This can be done with `SwingUtilities.invokeLater {}` or with coroutines if that is implemented. | ||
| 
               | 
          ||
| ```kotlin | ||
| val timeTravelServer = TimeTravelServer(runOnMainThread = { | ||
| SwingUtilities.invokeLater(it) | ||
| }) | ||
| timeTravelServer.start() | ||
| ``` | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if there is something else that should be added for the JVM
| 
           Big thanks for this!  | 
    
Overview
Update the time travel documentation based off some of the discussion
Issue
Closes #292