WARCRAFT FOREVER / DEVELOPERS
State and events
Read builds, react to changes, and clean up a mounted calculator.
ready resolves with the initial state. Use getState(), setBuild({ code, revision }), update(options), on(event, listener), and destroy() for later changes. on() returns an unsubscribe function. Updates resolve with committed state; an invalid build or revision rejects and leaves the previous state intact.
State includes the class, code, revision, full allocation, points spent and remaining, maximum level, completion, and standalone share URL. complete means a valid build has spent exactly maxLevel − 9 points. Listen for ready, change, complete, submit, or error. Save appears only when an editable build is complete; clicking it emits submit. change and the transition to complete describe user edits. API updates return state without emitting these edit events. Error listeners receive an Error object.
state.code remains the deprecated compact format for existing integrations. Call exportBuild('blizzard') for an in-game string or exportBuild('structured') for selected trees and spells. See build exports for the formats and revision requirements.
Mount after the target element and script exist. Multiple mounts are independent. Await an update before depending on it; a newer update or destroy rejects an unfinished update with AbortError. Updates preserve the current build unless you supply build; pass build: undefined to reset. Changing class without a new build resets its build and tree selection. Destroy on host component unmount. These scripts do not require React on your site.