Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

codegram/pinky

[EXPERIMENTAL] Composable promises for Elixir.

codegram/pinky.json
{
"createdAt": "2016-12-21T14:16:00Z",
"defaultBranch": "master",
"description": "[EXPERIMENTAL] Composable promises for Elixir.",
"fullName": "codegram/pinky",
"homepage": "https://hexdocs.pm/pinky",
"language": "Elixir",
"name": "pinky",
"pushedAt": "2016-12-21T15:24:02Z",
"stargazersCount": 7,
"topics": [],
"updatedAt": "2017-08-08T12:29:28Z",
"url": "https://github.com/codegram/pinky"
}

Travis Hex.pm

A promise library for Elixir.

Pinky promises are composable, even though their underlying machinery uses Elixir processes. Let’s see an example:

Pinky.promise(fn -> expensive_computation() end)
|> Pinky.map(fn result -> result + 5 end)
|> Pinky.flat_map(fn result ->
if result > 10 do
Pinky.promise(fn -> nested_computation(result) end)
else
Pinky.rejected("result too low")
end
end)
|> Pinky.extract # <- this call blocks until the whole promise is realized
# => {:ok, <some_result>}

Have a look at the API documentation to see detailed examples of each of the primitives.

The package can be installed by adding pinky to your list of dependencies in mix.exs:

def deps do
[{:pinky, "~> 0.2.0"}]
end