Skip to content

Commit

Permalink
add some state to the message.v example, to make it easier to test
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jan 3, 2025
1 parent 46b0585 commit 4531896
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions examples/hot_reload/message.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@ module main
import time
import v.live

struct App {
mut:
x int
counter int
}

@[live]
fn print_message() {
fn print_message(mut app App) {
info := live.info()
println('OK reloads: ${info.reloads_ok:4d} | Total reloads: ${info.reloads:4d} | Hello! Modify this message while the program is running.')
eprintln('>> app: ${voidptr(app)} | g_live_reload_info: ${voidptr(g_live_reload_info)}')
app.x = 9991 // try changing this to another value, while the program is running ...
app.counter++
dump(app)
}

fn main() {
unbuffer_stdout()
mut app := &App{}
for {
print_message()
print_message(mut app)
time.sleep(500 * time.millisecond)
}
}

0 comments on commit 4531896

Please sign in to comment.