Ash Framework for Phoenix Developers

Ash Framework for Phoenix Developers

Kamaro Lambert
This is a sample of the book's content.Buy on Leanpub

Table of Contents

Ash Framework for Phoenix Developers

  • Preface
  • Chapter 1: Thinking in Ash
    • 1.1 The Location of Ash In Your Application
    • 1.2 Describe(Model) Your Application
    • 1.3 Data all the way
  • Chapter 2: The Foundation: Resources and Domains
    • 2.1 Defining the Domain
    • 2.2 Resources
    • 2.3 Generate the Database with a Single Set of Commands
    • 2.4 Ash Resources Are Ecto Schemas
    • 2.5 Ash Resource and Elixir Protocol
  • Chapter 3: Actions
    • 3.1 Defining Actions on a Resource
    • 3.2 Creating Records
    • 3.2 Reading Record(s) with Ash.read
    • 3.3 Filter Condition With Ash.Query.filter
    • 3.4 Update Records with Ash.update
    • 3.5 Deleting Record(s) with Ash.destroy
    • 3.6 Generic Actions
  • Chapter 4: Relationships – How to Link Records
    • 4.1 Has Many Relationship
    • 4.2 How to Read Related Data with Ash.Query.load/2
    • 4.3 Belongs To Relationship
    • 4.4 Create Child and Parent at the Same Time
    • 4.5 Many To Many Relationship
    • 4.6 Has One
    • 4.7 Filtering With Relationships
    • 4.8 Retrieving Nested Relationships
    • 4.9 Deleting Records With Related Records
  • Chapter 5: Calculations and Aggregates
    • 5.1 Calculations
    • 5.2 Aggregates
  • Chapter 6: Validations
    • 6.1 Preventing Actions on Expired Invitations
  • Chapter 7: Authorization With Policies
  • Chapter 8: Code Interfaces
    • 8.1 Declaring Code Interface on a Resource
    • 8.2 Code Interface on the Domain
  • Part 2 - Wire Ash into Phoenix Applications
  • Chapter 9: Wiring Ash into Phoenix
    • 9.1 Ash + Phoenix Controller - Building Public Home Page
    • 9.1.1 Basic Home Page Layout
    • 9.1.2 Loading Categories with Aggregates (Best Practice)
    • 9.2 Ash + Phoenix LiveView – Admin CRUD
  • Chapter 10: LiveView and Real-Time Updates with Ash PubSub
    • 10.1 Enable Ash PubSub Notifications on the Category Resource
    • 10.2 Subscribe to Notifications in LiveView
    • 10.3 Bonus: Even More Efficient Updates (Optional)
  • Chapter 11: Don’t Repeat Yourself (DRY) in Ash
    • 11.1 DRY Your Forms – One Component for Create & Edit
    • 11.2 DRY Your Read Queries with Preparations
    • 11.3 DRY Your Create/ Update Logic with Changes
  • Chapter 12: Authentication
    • 12.1.1 Router Scope for Authentication
    • 12.2 Testing Your Application
    • 12.3 Authorization
  • Chapter 13: Convert Your Application into Multitenant
    • 13.1 Setting Up Teams (Tenant) Resource
    • 13.2 Make this resource multi-tenant
    • 13.3 Creating a Team and Auto-Linking the Owner User to the Team
    • 13.4 Ash Multitenancy: Automating User-Team Associations
    • 13.5 Associate Users with Teams
    • 13.6 Linking the User to the Team
    • 13.7 Setting the Owner’s Current Team
    • 13.8 Logged In User Tenant set
    • 13.9 Speeding Up Our Tests
    • 13.10 Making Liveview Tenant Aware
  • Chapter 14: Authorization in Ash Multitenancy
    • 14.1 Group Permissions
    • 14.2 Create and Edit Access Group Form
    • 14.3 List Access Group
    • 14.4 Assign Access Group Permission
  • Chapter 15: Background Jobs with Oban and Ash — Reliable Email Notifications
    • 15.1 Install Dependencies (Igniter Makes This Easy)
    • 15.2 Create the UserNotification Resource (The Heart of the System)
    • 15.3 Global Notify Function — Call It From Anywhere
    • 15.4 Send Real Emails with Swoosh + Mailtrap
    • 15.6 View & Debug Jobs with Oban Web
  • Chapter 16: CI and Auto Deployment
    • The Method
    • 16.1 Migrations in Production
    • 16.2 Deployment Shell Script
    • 16.3 Reverse Proxy Server Configurations.
    • 16.4 The Github Workflow Configuration
  • Chapter 17: Understanding Spark and the Extension System
    • 17.1 The Foundation: Code as Data in Elixir
    • 17.2 What is the Abstract Syntax Tree (AST)?
    • 17.3 Using quote to Capture Code as Data
    • 17.4 Using unquote to Inject Values into Quoted Code
    • 17.5 Introducing Spark: The Engine Behind Ash’s DSLs
    • 17.6 How Spark Works: A Simple Example
    • 17.7 A Real Ash Example
    • 17.8 Key Spark Concepts
    • 17.9 Why Spark’s Extension Model is Revolutionary
  • Chapter 18: Building Your First Ash Extension
    • 18.1 Basic Composition of an Ash Extension
    • 18.2 Start with Just the parent_id Attribute
    • 18.3 Add Relationships and Aggregate
    • 18.4 Usage Example
  • Chapter 19: Make Your Extension Configurable
    • 19.1 Delete Parent With Its Children
  • Chapter 20: Publish Your Extension To the World via Hex.pm
    • 20.1 Create Mix Package
    • 20.2 Move Extension Files to the New Package
    • 20.3 Update the Modules Namespace
    • 20.4 Test the Package Locally with Your Ash Application
    • 20.5 Publishing the Package to Hex.pm
    • 20.6 Adding Package Information
  • Appendix A: Ash Framework Cheat Sheet
    • Setup & Migrations
    • Domain & Resources (minimum)
    • Common Resource Sections
    • CRUD in IEx
    • Query & Filter
    • Relationships (manage_relationship)
    • Common Policy Checks
    • Authorization in Practice
    • Seed Data
    • Useful Ash Modules
  • Acknowledgments
Ash Framework for Phoenix Developers/Chapter 10: LiveView and Real-Time Updates with Ash PubSub

Chapter 10: LiveView and Real-Time Updates with Ash PubSub

https://leanpub.com/ash-phoenix

10.1 Enable Ash PubSub Notifications on the Category Resource

https://leanpub.com/ash-phoenix

10.2 Subscribe to Notifications in LiveView

https://leanpub.com/ash-phoenix

10.3 Bonus: Even More Efficient Updates (Optional)

https://leanpub.com/ash-phoenix

Previous

Chapter 9: Wiring Ash into Phoenix

Up next

Chapter 11: Don’t Repeat Yourself (DRY) in Ash

In this chapter

  • Chapter 10: LiveView and Real-Time Updates with Ash PubSub
  • 10.1 Enable Ash PubSub Notifications on the Category Resource
  • 10.2 Subscribe to Notifications in LiveView
  • 10.3 Bonus: Even More Efficient Updates (Optional)