From 2e4a948a07cc8b4f18930d1e390b697fb81a63ce Mon Sep 17 00:00:00 2001 From: Joannis Orlandos Date: Mon, 27 Nov 2017 00:19:27 +0100 Subject: [PATCH] Added futuretype docs --- 3.0/docs/async/futures.md | 2 +- 3.0/docs/async/futuretype.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 3.0/docs/async/futuretype.md diff --git a/3.0/docs/async/futures.md b/3.0/docs/async/futures.md index fca1ce98..718e384d 100644 --- a/3.0/docs/async/futures.md +++ b/3.0/docs/async/futures.md @@ -1,6 +1,6 @@ # Future basics -Futures are used throughout Vapor, so it is useful to know some of the available helpers. We explain the reasoning and use cases [here](../concepts/async.md). +Futures are used throughout Vapor, so it is useful to know some of the available helpers. We explain the reasoning and use cases [here](../concepts/async.md). They are the primary [`FutureType`](futuretype.md) implementation. ## Adding awaiters to all results diff --git a/3.0/docs/async/futuretype.md b/3.0/docs/async/futuretype.md new file mode 100644 index 00000000..3208ce01 --- /dev/null +++ b/3.0/docs/async/futuretype.md @@ -0,0 +1,7 @@ +# FutureType + +FutureType is a protocol defining any entity that provides the ability to register callback closures for an object that _may_ be returned in the future. + +FutureTypes call the registered closure with either an error or the `Expectation`. FutureTypes _may_ return this in the future. The can, instead, also call the closure immediately. + +This pattern is adopted by [`Response`](../http/response.md) among other types. We recommend libraries to be generic to FutureType rather than depending on a specific implementation such as [`Future`](futures.md)