Skip to content

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: EngineEvent
Engine.DIALOG_ABORT: EngineEvent
Engine.CONTENT_CHANGE: EngineEvent
Engine.CHAT: EngineEvent
Engine.FRIENDS: EngineEvent
Engine.CLAN: EngineEvent
Engine.CLAN_SETTINGS: EngineEvent
Engine.CLAN_CHANNEL: EngineEvent
Engine.MISC: EngineEvent
Engine.STOCK: EngineEvent
fires when
Engine.SUB_CHANGEany sub-interface opens or closes, anywhere in the tree
Engine.DIALOG_ABORTthe server aborts the current dialogue
Engine.CONTENT_CHANGEthe client’s content changes
Engine.CHATa chat message arrives
Engine.FRIENDSthe friend list moves
Engine.CLANthe friends-chat channel moves
Engine.CLAN_SETTINGSclan settings move
Engine.CLAN_CHANNELthe clan channel moves
Engine.MISCthe client’s miscellaneous update runs
Engine.STOCKthe Grand Exchange offers move
src/reference-engine.ts2
useWatch(Engine.SUB_CHANGE, (event) => { writeDivider(event.component); }, label);
  • The handler receives only event.component.
  • Only SUB_CHANGE and DIALOG_ABORT fire 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”
src/reference-engine.ts2
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} />
);
};
src/reference-engine.ts2
useRerenderOn(Engine.CHAT);

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.