Cross-cutting utilities
Loose functions with no search-specific meaning — building a query from the current route, reading route metadata, running code in a Web Worker, and a fetch wrapper with baseline error handling.
buildQuery / getQueryNameFromRoute — a query from the current route
import { Component, inject } from "@angular/core";
import { buildQuery } from "@sinequa/atomic-angular";
import { fetchQuery } from "@sinequa/atomic";
@Component({ selector: "sample-component", template: `` })
export class SampleComponent {
async search() {
// Merges (in order): URL params → the route's queryName data → your overrides.
const query = buildQuery({ text: "quarterly report" });
return fetchQuery(query);
}
}buildQuery(partial) resolves the query's name by checking, in order: partial.name,
getQueryNameFromRoute() (the active route's queryName route data, or the current tab's t query
parameter matched against the app's search route children), then the URL's own stored parameters — and
merges everything else from the URL underneath your partial. Both must run inside an injection context.
getCurrentPath / getCurrentQueryName — reading route metadata
import { getCurrentQueryName } from "@sinequa/atomic-angular";
// Inside an injection context:
const queryName = getCurrentQueryName(); // reads Router.config, matched against the current pathDistinct from getQueryNameFromRoute() above: this one matches the current URL path against the static
Router.config, rather than walking the live ActivatedRoute tree — useful outside a component that has an
injected ActivatedRoute of its own.
InlineWorker — running a function in a Web Worker
import { InlineWorker } from "@sinequa/atomic-angular";
const worker = new InlineWorker(() => {
// This function's body is stringified and run as the worker's whole script —
// it cannot close over anything from the surrounding scope.
self.onmessage = (e) => self.postMessage(e.data * 2);
});
worker.onmessage().subscribe((event) => console.log(event.data));
worker.postMessage(21);
worker.terminate();onmessage()/onerror() return RxJS Observables rather than plain callbacks. Throws synchronously if
Worker is unavailable in the current environment (a non-browser SSR context, most often).
withFetch — a fetch wrapper with baseline error handling
import { withFetch } from "@sinequa/atomic-angular";
const data = await withFetch(() => fetch("/api/data").then((res) => res.json()), injector);Catches the callback's rejection and logs it; on a 401 it also shows a warning toast and, if an injector
was passed, re-triggers the sign-in flow. Returns undefined on any error rather than rethrowing — check for
undefined at the call site instead of wrapping the call in try/catch.
Options
Prop
Type
Pitfalls
Cross-cutting pipes
Six template pipes with no search-specific meaning of their own — legacy filter display, a translated system string, locale-aware dates, file sizes, and search-term highlighting.
Cross-cutting services
Registering your own route components, sending custom audit events, calling a JsonMethod plugin, and reading the route the user navigated away from.