Build your first Multisynq application - a synchronized counter that updates in real-time across all users
init()
- Model InitializationModel Initialization Details
this.count = 0
: Initialize our counter statethis.subscribe("counter", "reset", this.resetCounter)
: Listen for reset events from the viewthis.future(1000).tick()
: Schedule the first tick in 1 secondinit()
only runs once when a session starts. After that, the model state is automatically saved and restored for new users joining.resetCounter()
- Handle Reset Eventstick()
- The Heartbeatthis.future(1000).tick()
is a powerful Multisynq feature that schedules method calls in the future. This ensures perfect synchronization across all users.register()
- Class Registrationconstructor(model)
- View SetupConstructor Details
super(model)
: Call the parent View constructorthis.model = model
: Store model reference for read-only accesscountDisplay.onclick = ...
: Set up click handlerthis.subscribe("counter", "changed", ...)
: Listen for counter changesthis.counterChanged()
: Update display immediatelycounterReset()
- Handle User ClickscounterChanged()
- Update DisplayMultisynq.Session.join()
:
Multisynq.App.autoSession()
for auto-generated namesMultisynq.App.autoPassword()
for auto-generated passwordsCounter not updating
MyModel.register("MyModel")
is calledtick()
method is being calledMultiple users not synchronized
appId
QR code not working
"your_api_key_here"
with your actual API key from multisynq.io/coder!