Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dkuku/return_helpers
elixir helpers for easy continuing pipe chain
https://github.com/dkuku/return_helpers
Last synced: 18 days ago
JSON representation
elixir helpers for easy continuing pipe chain
- Host: GitHub
- URL: https://github.com/dkuku/return_helpers
- Owner: dkuku
- Created: 2020-04-29T21:13:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-07T10:54:30.000Z (over 4 years ago)
- Last Synced: 2024-12-06T19:40:15.807Z (about 1 month ago)
- Language: Elixir
- Homepage:
- Size: 87.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Elixir Return Helpers
[![Coverage Status](https://coveralls.io/repos/github/dkuku/return_helpers/badge.svg?branch=master)](https://coveralls.io/github/dkuku/return_helpers?branch=master)
## Description
Simple library that adds a piping possibility for easy returning from pipes
Documentation https://hexdocs.pm/return_helpers/api-reference.html
Imagine
```elixir
socket =
socket
|> assign(valid: true)
{:noreply, socket}
```to write like:
```elixir
socket
|> assign(valid: true)
|> noreply()
```or:
```elixir
socket |> assign(valid: true) |> noreply()
```Looks cleaner ?
## Examples
```elixir
iex> %{} |> ok()
{:ok, %{}}iex> %{} |> noreply()
{:noreply, %{}}iex> %{} |> to_tuple(:error, "params")
{:error, %{}, "params"}iex> "34" |> between_strings("12", "56")
"123456"
```## Helpers provided
- error/1
- noreply/1
- noreply/2
- noreply/3
- ok/1
- ok/2
- reply/1
- reply/2
- reply/3
- stop/1
- stop/2
- stop/3
- to_tuple/2
- to_tuple/3
- between_strings/3## Installation
By adding `return_helpers` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:return_helpers, "~> 0.1.0"}
]
end
```## Usage with liveview
```
defp view_helpers do
quote do
...
import ReturnHelpers
end
end
```
globally for views