| 1 | module main |
| 2 | |
| 3 | // Build this example with `v -live message.v` |
| 4 | import time |
| 5 | import v.live |
| 6 | |
| 7 | struct App { |
| 8 | mut: |
| 9 | x int |
| 10 | c int |
| 11 | } |
| 12 | |
| 13 | @[live] |
| 14 | fn print_message(mut app App) { |
| 15 | i := live.info() |
| 16 | println('Hello! Modify this message. OK reloads: ${i.reloads_ok:2d} | Total: ${i.reloads:2d} | app: ${voidptr(app)} | app.c: ${app.c:4} | app.x: ${app.x:12}') |
| 17 | // app.x = app.x * 3 + 1 // try changing this to another value, while the program is running ... |
| 18 | // app.x = 0 |
| 19 | app.c++ |
| 20 | } |
| 21 | |
| 22 | fn main() { |
| 23 | unbuffer_stdout() |
| 24 | println('=============================================================') |
| 25 | println('== Modify the message below, while the program is running: ==') |
| 26 | println('=============================================================') |
| 27 | mut app := &App{} |
| 28 | for { |
| 29 | print_message(mut app) |
| 30 | time.sleep(500 * time.millisecond) |
| 31 | } |
| 32 | } |
| 33 | |