All Scopes multiplayer
Change a status that every visitor sees, a counter shared by everyone on this page, and a message only your tab sees. The three cards are components in GLOBAL, ROUTE and TAB scope; Page A and Page B each get their own ROUTE counter.
withWorkerNum().Shared across ALL pages and users. Changes propagate everywhere.
Shared by all users on THIS page only. Different pages have different counters.
Private to this browser tab. Other tabs have their own value.
Page A
Notice: Global status is the SAME as Home, but the Route counter is DIFFERENT (this is Page A's counter).
Signals
personalMessage
string tab scope initial: "Hello from your personal tab!" Per-tab editable message. Private to each browser tab.
Actions
updateStatus
Randomizes the system status, counts the visit in GlobalState and broadcasts Scope::GLOBAL.
increment
Increments the page-specific shared counter and broadcasts the page's ROUTE scope.
reset
Resets the page-specific counter to 0 and broadcasts the page's ROUTE scope.
updateMessage
Randomizes the personal tab message. The new value goes to the tab after the action, with no broadcast.
Views
all_scopes.html.twig
Page shell with navigation between sub-pages.
Global banner
GLOBAL-scoped component showing system status shared across all pages and users.
Route counter
ROUTE-scoped component with a counter shared between all tabs on the same page.
Tab message
TAB-scoped component with a private editable message per browser tab.