From 1907e35fdff56ae606381cd351662ab8f46ccc22 Mon Sep 17 00:00:00 2001 From: Tom Elliott Date: Wed, 29 Jan 2025 12:02:14 +1300 Subject: [PATCH] working on example app --- vignettes/faithful-app.R | 4 ++-- vignettes/simple-react-app.Rmd | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/vignettes/faithful-app.R b/vignettes/faithful-app.R index fba9d4f..ce47544 100644 --- a/vignettes/faithful-app.R +++ b/vignettes/faithful-app.R @@ -5,12 +5,12 @@ get_hist <- ts_function( h <- hist(faithful$waiting, breaks = bins, plot = FALSE) data.frame(x = h$mids, y = h$density) }, - result = ts_dataframe(eruptions = ts_numeric(), waiting = ts_numeric()) + result = ts_dataframe(x = ts_numeric(0), y = ts_numeric(0)) ) get_smoother <- ts_function( function(bandwidth = ts_numeric(1)) { d <- density(faithful$waiting, bw = bandwidth) data.frame(x = d$x, y = d$y) }, - result = ts_dataframe(x = ts_numeric(), y = ts_numeric()) + result = ts_dataframe(x = ts_numeric(0), y = ts_numeric(0)) ) diff --git a/vignettes/simple-react-app.Rmd b/vignettes/simple-react-app.Rmd index bbaa06e..e117026 100644 --- a/vignettes/simple-react-app.Rmd +++ b/vignettes/simple-react-app.Rmd @@ -34,9 +34,7 @@ source('faithful-app.R') get_hist$call(10) ``` -That's it! We'll use `ts_deploy()` later to create the server code and Typescript schema for the app. - -TODO: call ts_compile() from ts_deploy()? +That's it! We'll use `ts_compile()` later to create the server code and Typescript schema for the app. ## Create the React app @@ -57,7 +55,7 @@ pnpm install rserve-ts zod ### Create the server code -We now use the `ts_deploy()` function to create two files: +We now use the `ts_compile()` function to create two files: - `faithful-app.rserve.R` is the file that will start the Rserve instance with your apps functions available. - `faithful-app.rserve.ts` contains the TypeScript schema (using [zod](https://zod.dev)) that will let you use the R functions directly in the app like any other typescript function! @@ -65,8 +63,7 @@ We now use the `ts_deploy()` function to create two files: We'll send these straight to the `faithful-demo/src` directory. ```r -ts_compile('faithful-app.R', file = 'faithful-demo/src/faithful-app.rserve.ts') -ts_deploy('faithful-app.R', file = 'faithful-demo/src/faithful-app.rserve.R') +ts_compile('faithful-app.R', filename = 'faithful-demo/src/faithful-app.rserve') ``` ### Write the app