Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { provide, Provide } from '@sgrud/core';
import { Observable } from 'rxjs';
import { Router } from '../router/router';
/**
* Abstract base class to implement {@link Router} **Queue**s. By applying the
* {@link Target} decorator or otherwise providing an implementation of this
* abstract **Queue** base class to the {@link Linker}, the implemented
* {@link handle} method is called whenever a new {@link Router.State} is
* triggered by navigating. This interceptor-like pattern makes complex routing
* strategies like asynchronous module-retrieval and the similar tasks easy to
* be implemented.
*
* @decorator {@link Provide}
*
* @example
* Simple **Queue** stub:
* ```ts
* import { Provider, Target } from '@sgrud/core';
* import { type Router, type Queue } from '@sgrud/shell';
* import { type Observable } from 'rxjs';
*
* @Target()
* export class ExampleQueue
* extends Provider<typeof Queue>('sgrud.shell.Queue') {
*
* public override handle(
* prev: Router.State,
* next: Router.State,
* queue: Router.Queue
* ): Observable<Router.State> {
* throw new Error('Stub!');
* }
*
* }
* ```
*
* @see {@link Route}
* @see {@link Router}
*/
@Provide()
export abstract class Queue {
/**
* Magic string by which this class is {@link provide}d.
*
* @see {@link provide}
*/
public static readonly [provide]: 'sgrud.shell.Queue' = 'sgrud.shell.Queue';
/**
* Abstract **handle** method, called whenever a new {@link Router.State}
* should be {@link Router.navigate}d to. This method provides the possibility
* to intercept these upcoming {@link Router.State}s and, e.g., mutate or
* redirect them, i.e., **handle** the navigation.
*
* @param prev - The `prev`iously active {@link Router.State}.
* @param next - The `next` {@link Router.State} {@link Router.navigate}d to.
* @param queue - The next {@link Queue} to **handle** the navigation.
* @returns An {@link Observable} of the **handle**d {@link Router.State}.
*/
public abstract handle(
prev: Router.State,
next: Router.State,
queue: Router.Queue
): Observable<Router.State>;
}
|