Adding onQuery function to allow callbacks to be invoked any time the state attributes change