Skip to content

Commit

Permalink
docs: Replace handle_on with run_on in the docs. #1484
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Sep 19, 2023
1 parent 93bc110 commit 2cc0783
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions website/docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,14 @@ async def serve(q: Q):

### Reducing boilerplate

As your application gets larger, using the above `if/elif/else` conditionals can seem tedious or repetitive. If so, you can use `on` and `handle_on` to reduce the boilerplate.
As your application gets larger, using the above `if/elif/else` conditionals can seem tedious or repetitive. If so, you can use `on` and `run_on` to reduce the boilerplate.

:::warning
In versions `<1.0` this function used to be called `handle_on`, but is now deprecated due to its drawbacks that the new `run_on` mechanism addressed.
:::

```py {3,7,22}
from h2o_wave import Q, main, app, ui, on, handle_on
from h2o_wave import Q, main, app, ui, on, run_on

@on('#heads')
async def on_heads(q: Q):
Expand All @@ -179,7 +183,7 @@ async def setup_page(q: Q):

@app('/toss')
async def serve(q: Q):
if not await handle_on(q):
if not await run_on(q):
await setup_page(q)

await q.page.save()
Expand Down

0 comments on commit 2cc0783

Please sign in to comment.