Skip to content

Commit 15bbbd9

Browse files
author
Adriano Santos
committed
docs: added phoenix liveview integration page
1 parent f2ec9c3 commit 15bbbd9

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
- 6.2 [Conceptual](conceptual.md)
6464
- 6.3 [Main Concepts](main.md)
6565
- 6.5 [Durable Computing](durable.md)
66+
- 6.6 [Integration with Elixir Phoenix Liveview](phoenix.md)
6667

6768
[Next: Overview](overview.md)
6869

docs/phoenix.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Integration with Elixir Phoenix Liveview
2+
3+
Spawn offers seamless integration with [Phoenix LiveView](https://www.phoenixframework.org/), using the [Phoenix PubSub](https://hexdocs.pm/phoenix/1.1.0/Phoenix.PubSub.html) system to enable real-time communication and live updates between distributed actors and web interfaces. This powerful combination allows developers to create interactive, real-time web applications with Phoenix while maintaining backend services in any language supported by Spawn.
4+
5+
## **How It Works**
6+
7+
1. **Actors Emit Events:**
8+
Spawn actors, implemented in any supported language, generate events or state changes as part of their workflows.
9+
10+
2. **Forwarding to Phoenix PubSub:**
11+
These events are forwarded to Phoenix PubSub topics using Spawn's native broadcast adapter, enabling LiveView processes to subscribe and react in real time.
12+
13+
3. **Real-Time Updates in LiveView:**
14+
State changes emitted by Spawn actors are instantly reflected in the LiveView interface, providing users with a seamless and dynamic experience.
15+
16+
## **Effortless Event Broadcasting**
17+
18+
Integrating Spawn with Phoenix LiveView is straightforward. Spawn actors simply emit broadcast events via Spawn's native adapter. Any Phoenix application within the same Spawn cluster can listen to these events by subscribing with [Phoenix.PubSub.subscribe](https://hexdocs.pm/phoenix/1.1.0/Phoenix.PubSub.html#subscribe/4).
19+
20+
### **Example**
21+
22+
You can explore practical examples of this integration in the links below:
23+
24+
* [Match Actor Implementation](https://github.com/eigr-labs/spawn_game_example/blob/main/lib/dice/game/match_actor.ex)
25+
26+
* [LiveView Component](https://github.com/eigr-labs/spawn_game_example/blob/main/lib/dice_web/live/game_page_live.ex)
27+
28+
With Spawn and Phoenix LiveView, building real-time, distributed systems with rich web interfaces becomes intuitive and highly scalable.

0 commit comments

Comments
 (0)