Manage before and after callbacks for a generator