Implemented promises API.