Engine
Engine names the ten things the client announces that are not values: a chat
message arrived, a sub-interface opened or closed, the clan settings moved.
Each is an
occasion a useWatch can wait for, or
a useRerenderOn can redraw on.
Engine.SUB_CHANGE: EngineEventEngine.DIALOG_ABORT: EngineEventEngine.CONTENT_CHANGE: EngineEventEngine.CHAT: EngineEventEngine.FRIENDS: EngineEventEngine.CLAN: EngineEventEngine.CLAN_SETTINGS: EngineEventEngine.CLAN_CHANNEL: EngineEventEngine.MISC: EngineEventEngine.STOCK: EngineEventReference
Section titled “Reference”The ten occasions
Section titled “The ten occasions”| fires when | |
|---|---|
Engine.SUB_CHANGE | any sub-interface opens or closes, anywhere in the tree |
Engine.DIALOG_ABORT | the server aborts the current dialogue |
Engine.CONTENT_CHANGE | the client’s content changes |
Engine.CHAT | a chat message arrives |
Engine.FRIENDS | the friend list moves |
Engine.CLAN | the friends-chat channel moves |
Engine.CLAN_SETTINGS | clan settings move |
Engine.CLAN_CHANNEL | the clan channel moves |
Engine.MISC | the client’s miscellaneous update runs |
Engine.STOCK | the Grand Exchange offers move |
useWatch(Engine.SUB_CHANGE, (event) => { writeDivider(event.component); }, label);Caveats
Section titled “Caveats”- The handler receives only
event.component. - Only
SUB_CHANGEandDIALOG_ABORTfire on a host in a box 0 wide or 0 tall.
Rewriting a label when a panel opens or closes
Section titled “Rewriting a label when a panel opens or closes”export const SubChangeDivider = (): Component => { const label = useRef(); useWatch(Engine.SUB_CHANGE, (event) => { writeDivider(event.component); }, label);
return ( <text ref={label} x={0} y={0} w="fill" h={14} text="No panel has opened yet" font={Fonts.SMALL} align="center" valign="middle" shadow color={Colors.DIM} /> );};Redrawing when a message arrives
Section titled “Redrawing when a message arrives” useRerenderOn(Engine.CHAT);Troubleshooting
Section titled “Troubleshooting”Which do I want, a watch or a re-render?
Section titled “Which do I want, a watch or a re-render?”A watch when a handler can say the change — a text, a colour, a hide. A
re-render when the tree’s shape changes — a component appears or goes.