Angel3 Developer Guide
  • README
  • Foreword
  • Tutorial
    • Getting Started
    • Minimal Setup
  • Command Line Interface
    • Setup
  • Templates and Views
    • Server Side Rendered Views
    • JAEL3
      • About
      • Basics
      • Custom Elements
      • Strict Resolution
      • Directive: declare
      • Directive: for-each
      • Directive: extend
      • Directive: if
      • Directive: include
      • Directive: switch
  • Authentication
    • About
    • Strategies
    • Local
  • Databases
    • Object Relational Mapping (ORM)
      • About
      • Basic Functionality
      • Relations
      • Migrations
      • PostgreSQL
    • NoSQL
  • Extensions and Plugins
    • Using Plug-ins
    • Writing a Plugin
  • Under the hood
    • Basic Routing
    • Requests & Responses
    • Request Lifecycle
    • Dependency Injection
    • Middleware
    • Controllers
    • Parsing Request Bodies
    • Serialization
    • Service Basics
    • Testing
    • Error Handling
    • Pattern Matching and Parameter
  • Angel Framework Migration
    • Angel 2.x.x to Angel3
      • Rationale - Why a new Version?
      • Framework Changelog
      • 3.0.0 Migration Guide
    • Angel 1.x.x to 2.x.x
      • Framework Changelog
      • 2.0.0 Migration Guide
  • Packages
    • Authentication
    • CORS
    • Database-Agnostic Relations
    • Configuration
    • Databases
      • ORM
      • MongoDB
      • JSON File-based
      • RethinkDB
    • Templates and Views
      • Jael template engine
      • Mustache Templates
      • compiled_mustache-based engine
      • html_builder-based engine
      • Markdown template engine
      • Using Angel with Angular
    • Hot Reloading
    • Pagination
    • Polling
    • Production Utilities
    • REST Client
    • Reverse Proxy
    • Router
    • Serialization
    • Service Seeder
    • Static Files
    • Security
    • Server-sent Events
    • shelf Integration
    • Task Engine
    • User Agents
    • Validation
    • Websockets
  • Resources
    • Dependency Injection Patterns
    • Example Projects
    • YouTube Tutorials
    • Ecosystem
Powered by GitBook
On this page
  • Using Plug-ins
  • Execution Order
  • Next Up

Was this helpful?

  1. Extensions and Plugins

Using Plug-ins

PreviousExtensions and PluginsNextWriting a Plugin

Last updated 3 years ago

Was this helpful?

Using Plug-ins

Angel3 is designed to be extensible. As such, it exposes a typedef, AngelConfigurer, that has special privileges within the framework - they act as plug-ins and can be called via app.configure().

Plug-ins simply need to accept an Angel instance as a parameter, and return a Future (the result of which will be ignored, unless it throws an error). Angel instances have several facilities available to be customized, and thus it is easy to use a custom plug-in to bring about desired functionality within your application.

typedef Future AngelConfigurer(Angel app);

As a convention, Angel3 plug-ins should be hooked up before the call to startServer.

import 'dart:io';
import 'package:angel3_framework/angel3_framework';

plugin(Angel app) async {
  print("Do stuff here");
}

void main() async {
  Angel app = Angel();
  await app.configure(plugin);
  await app.startServer();
}

Execution Order

app.startupHooks.addAll([
  myPlugin(),
  AngelWebSocket().configureServer,
  fooBarBazQuux()
]);

Likewise, you can add hooks that run just before the app is shutdown, via Angel.shutdownHooks.

Next Up

Learn how to generate content for clients by rendering views.

Plugins are usually immediately invoked by app.configure(). However, you may run into certain plug-ins that depend on other facilities already being available, or all of your already being mounted. You can set aside a plug-in to be run just before server startupby adding it to app.startupHooks, instead of directly calling app.configure().

services
Writing a Plug-in
Using Plug-ins
Execution Order
Next Up...