Skip to content

Commit

Permalink
Update cloud-variables.md
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Apr 10, 2024
1 parent 651eb0a commit 189027a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/website/cloud-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ while True:
print(f"{variable_name} is {value}")
```

Where `cloudlibrary.get_var` is implemented by opening a connection and then closing it immediately. Instead, libraries should offer [event-driven](https://en.wikipedia.org/wiki/Event-driven_programming) APIs. Instead of constantly asking the server for the latest values, open exactly one WebSocket, and let the server send updates as they happen. WebSockets are very efficient: If no variables are changing, the connection remains idle. If there are a lot of variables changing, you'll the updates as soon as possible. Equivalent code might instead be:
Where `cloudlibrary.get_var` is implemented by opening a connection and then closing it immediately. Instead, libraries should offer [event-driven](https://en.wikipedia.org/wiki/Event-driven_programming) APIs. Instead of constantly asking the server for the latest values, open exactly one WebSocket, and let the server send updates as they happen. WebSockets are very efficient: If no variables are changing, the connection remains idle. If there are a lot of variables changing, you'll get the updates as soon as possible. Equivalent code might instead be:

```py
def on_set(name, value):
Expand Down

0 comments on commit 189027a

Please sign in to comment.