updated router class to emit a "statechange" event