Appearance
Api plugins
An api plugin in Alette Signal is a module defining and configuring request blueprints before exposing them for usage. On its own blueprint() contains no middleware, and needs to be defined and configured by plugin authors using built-in middleware.
Core plugin blueprints
Alette Signal core plugin exposes 3 configured request blueprints out of the box:
- Query - preconfigured for
GETHTTP requests. - Mutation - preconfigured for
POST,PATCH,DELETEandPUTHTTP requests. - Custom - used for executing dependent requests, or creating custom request behaviours by composing middleware.
ts
import { coreApiPlugin } from '@alette/signal';
export const core = coreApiPlugin();
export const { query, mutation, custom } = core.use();INFO
Alette Signal treats query(), mutation() and custom() as middleware "black boxes", nothing more. The same is true for any blueprints plugin authors may define.
DANGER
A plugin must be activated for its request blueprints to work.
Api plugin activation
To activate api plugins, use activatePlugins() api instruction:
ts
import { client, activatePlugins, coreApiPlugin } from "@alette/signal";
import { core } from './base.ts'
export const api = client(
/* ... */
activatePlugins(core.plugin),
);DANGER
Api plugins must be activated for their request blueprints to work.
Api plugin deactivation
To deactivate api plugins, use deactivatePlugins() api instruction:
ts
api.tell(deactivatePlugins(core.plugin))DANGER
During plugin deactivation all in-flight requests created from its request blueprints are interrupted.