Listen to statechange to determine when the worker is ready.