DataFetcher.result

You're seeing just the function result, go back to DataFetcher module for more information.

Specs

result(fetcher_name :: atom()) :: any()

Get result of the fetch.

Parameters

  • name - atom, the identifier of the fetch job

Returns

  • any

When called, if the data is still being fetched at the first round, it will wait until the data is successfully fetched before returning the result. Otherwise, data is read from the cache and returned immediately.

Example

iex> opts = [
...>   name: :function_fetcher,
...>   fetcher: fn -> {:ok, %{foo: 1}} end
...> ]
...>
...> {:ok, _} = Supervisor.start_link([{DataFetcher, opts}], strategy: :one_for_one)
...>
...> DataFetcher.result(:function_fetcher)
%{foo: 1}