Implement logic for promise-like behaviour.