From the course: Learning Combine with Swift

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Publish data once with Future and Just

Publish data once with Future and Just - Swift Tutorial

From the course: Learning Combine with Swift

Start my 1-month free trial

Publish data once with Future and Just

- [Instructor] Just and Future are two special types of publishers commonly used in Combine. Just omits a single result before either terminating successfully or failing. You could use Just to wrap around a primitive value, say a string or number into a publisher with simplicity and have it return just once. Future on the other hand wraps a request response into a single result, either as an output value or failure completion. It doe so by wrapping any asynchronous call such as a REST end point in to a publisher. You will commonly use this when you want to make a single request and get back a single response. And an example of something you may want to wrap into a publisher is Apple's own permissions requesting framework. A promise is a closure that returns a result from a future call that you can use to either ingest resulting values or resulting error. Now let's transition from theory into practice and take a look at…

Contents