Tutorial API Callbacks

Workbench

As seen in the examples in Tutorial API Methods, the callback returns JSON. The following are examples of calls that trigger callbacks.

Method Description Example payload
getState response from getState See examples below
error a prior API call failed {“message”: “error”, “api”: “createProjFromGit”, “result”: “access denied”, “callerID”: “abcd”}
success a prior API call succeeded {“message”: “success”, “api”: “createProjFromGit”, “callerID”: “abcd”}

There are also callbacks sent directly by RStudio Pro (i.e. not in response to Tutorial API calls).

Method Description Example payload
fileSave contents of a file loaded in RStudio Pro IDE were saved (including auto-save of content and/or metadata) {“message”: “fileSave”}
sessionDisconnect connection between RStudio Pro IDE and its rsession process was closed {“message”: “sessionDisconnect”}
sessionSuspend the rsession process has been suspended {“message”: “sessionSuspend”}

getState

The getState() method returns the path to the currently loaded .Rproj (if any) and any git remotes.

The results come via the callback. Here are some examples.

Project with remotes

{
  "message": "getState",
  "callerID": "abcd",
  "project": "~/aaa/aaa.Rproj",
  "remotes": [
    {
      "active": true,
      "remote": "origin",
      "type": "fetch",
      "url": "https://github.com/rstudio/aaa"
    },
    {
      "active": true,
      "remote": "origin",
      "type": "push",
      "url": "https://github.com/rstudio/aaa"
    }
  ]
}

Project with no remotes

{
  "message": "getState",
  "callerID": "abcd",
  "project": "~/localproj/localproj.Rproj",
  "remotes": []
}

No project and no remotes

{
  "message": "getState",
  "callerID": "abcd",
  "project": null,
  "remotes": []
}