Related to: https://linear.app/comm/issue/ENG-9803/make-sure-peertopeermessagehandler-run-after-persisted-state-is-read
Web and native use similar mechanism for checking when state is read.
This diff unifies it and moves to lib package in order to use it later in PeerToPeerMessageHandler.