ZuraffaPlugin class abstract

Abstract contract that every Zuraffa micro-frontend plugin must implement.

A ZuraffaPlugin declares four capabilities that the host application consumes through the ZuraffaEngine:

  1. Identity -- pluginId uniquely identifies the plugin within the engine. Duplicates are rejected at registration time.
  2. Dependency registration -- registerDependencies is called during the engine's bootstrap phase so the plugin can register its services into the shared ZuraffaDIContainer.
  3. Route contribution -- routes returns the map of route names to ZuraffaRouteBuilder functions.
  4. Async initialisation -- onInit runs after all plugins have registered their dependencies, giving each plugin a chance to perform async work before the app becomes interactive.

Lifecycle

The engine orchestrates plugins through two phases:

  1. Registration phase -- registerDependencies is called for every plugin in insertion order. Only registrations.
  2. Init phase -- onInit is called for every plugin. All dependencies from all plugins are now available.

Example

class UserProfilePlugin extends ZuraffaPlugin {
  @override
  String get pluginId => 'user_profile';

  @override
  void registerDependencies(ZuraffaDIContainer di) {
    di.registerLazySingleton<UserRepository>(() => UserRepositoryImpl());
    di.registerFactory<ProfileBloc>(() => ProfileBloc(di.get()));
  }

  @override
  Map<String, ZuraffaRouteBuilder> get routes => {
    '/profile': (context, args) => ProfilePage(),
    '/profile/edit': (context, args) => ProfileEditPage(),
  };

  @override
  Future<void> onInit(ZuraffaDIContainer di) async {
    final repo = di.get<UserRepository>();
    await repo.warmCache();
  }
}
Implementers

Constructors

ZuraffaPlugin()

Properties

hashCode → int
The hash code for this object.
no setterinherited
pluginId → String
Unique identifier for this plugin.
no setter
routes → Map<String, ZuraffaRouteHandler>
Route table contributed by this plugin.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDispose(ZuraffaDIContainer di) → Future<void>
Disposal hook called by ZuraffaEngine.shutdown in reverse registration order (spec 025 — package runtime modules).
onInit(ZuraffaDIContainer di) → Future<void>
Asynchronous initialisation hook called after all plugins have completed registerDependencies.
onReady(ZuraffaDIContainer di) → Future<void>
Readiness hook called by ZuraffaEngine.ready after bootstrap has completed for every plugin (spec 025 — package runtime modules).
registerDependencies(ZuraffaDIContainer di) → void
Registers this plugin's dependencies into the shared di container.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited