Need help with using PushState library listeners

I am using the PushState library and I am having difficulty getting the listener function to fire when using the browser controls. Whenever the browser URL changes, the function should trigger.

I have no such difficulty when I compile the demo so I think my problems are because I’m using PushState within a PureMVC framework. The Mediators within PureMVC are persistent, and when the URL change is initiated from within Haxe (via the updatePushState function below), the listener works fine.

Does anyone have any ideas on how I can get the listener properly connected to the browser event? Is there an “expose” trick or something?


    class ExternalInterfaceMediator extends Mediator implements IMediator
    {
       
	public static inline var NAME:String = "ExternalInterfaceMediator";
        public function new ( viewComponent:Any ) {
		super( NAME, viewComponent );
        }

	public function setupPushState(basePath:String):Void {
		PushState.init(  );
		PushState.addEventListener(
			psListen
		);
        }
        public function psListen (url:String, state:Dynamic):Void{
		trace("pushstate heard:"+url);
		trace("pushstate saw:"+state);
        }
        public function updatePushState(path:String):Void {
            PushState.push(path);
        }
    }

Problem solved. PushState was only adding its listeners when the DOMContentLoaded event fired and needed to be more versatile. Added code for deferred init by ConfidantCommunications · Pull Request #12 · jasononeil/hxpushstate · GitHub