Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vanderhoop/slender_channel
A small, dependency-free module that exposes helpful macros for working with Phoenix Channels.
https://github.com/vanderhoop/slender_channel
elixir elixir-library hex-package phoenix-channels phoenix-framework
Last synced: about 1 month ago
JSON representation
A small, dependency-free module that exposes helpful macros for working with Phoenix Channels.
- Host: GitHub
- URL: https://github.com/vanderhoop/slender_channel
- Owner: vanderhoop
- Created: 2017-04-25T03:52:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T02:59:18.000Z (over 4 years ago)
- Last Synced: 2024-09-18T14:10:51.324Z (4 months ago)
- Topics: elixir, elixir-library, hex-package, phoenix-channels, phoenix-framework
- Language: Elixir
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
[![CircleCI](https://circleci.com/gh/vanderhoop/slender_channel.svg?style=shield)](https://circleci.com/gh/stride-nyc/remote_retro)
[![Hex.pm](https://img.shields.io/hexpm/v/slender_channel.svg)]()# SlenderChannel
A small, dependency-free module that exposes helpful macros for working with Phoenix Channels.
## Usage
The package can be installed by adding `slender_channel` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:slender_channel, "~> 0.2.0"}]
end
```To leverage `SlenderChannel`'s macros, simply `use` it within your Phoenix Channel:
```elixir
defmodule YourPhoenixApp.YourChannel do
use YourPhoenixApp.Web, :channel
use SlenderChannel# ...
end
```And leverage the macros within said channel.
```elixir
handle_in_and_broadcast "bobby_dumped_stacy", %{"pettiness" => 10}handle_in_and_broadcast_from "urgent message", %{"ETA" => "10 minutes"}
```Under the hood, becomes:
```elixir
def handle_in("bobby_dumped_stacy", %{"pettiness" => 10}, socket)
Phoenix.Channel.broadcast! socket, "bobby_dumped_stacy", %{"pettiness" => 10}
{:noreply, socket}
enddef handle_in("urgent message", %{"ETA" => "10 minutes"}, socket) do
Phoenix.Channel.broadcast_from! socket, "urgent message", %{"ETA" => "10 minutes"}
{:noreply, socket}
end
```