Skip to content

codegram/pinky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Installation

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

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

About

[EXPERIMENTAL] Composable promises for Elixir.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages