Open History to see the last commit
1import { Injectable } from '@angular/core'
2import { of, tap } from 'rxjs'
3import { delay } from 'rxjs/operators'
4β
5@Injectable({
6 providedIn: 'root',
7})
8export class PostsService {
9 allPosts$ = () =>
10 of(posts).pipe(
11 tap(() => console.log('fetching posts')),
12 delay(50),
13 )
14}
15β
16export interface Post {
17 id: number
18 title: string
19 body: string
20}
21β
22const posts: Array<Post> = [
23 {
24 id: 1,
25 title: 'Render on the server',
26 body: 'The initial HTML is produced by Angular SSR before the browser bootstraps the app.',
27 },
28 {
29 id: 2,
30 title: 'Hydrate on the client',
31 body: 'Angular reuses the rendered DOM and turns it into a live client application.',
32 },
33 {
34 id: 3,
35 title: 'Query on both sides',
36 body: 'TanStack Query resolves during server rendering, then transfers the hydrated cache to the browser.',
37 },
38 {
39 id: 4,
40 title: 'No API needed',
41 body: 'This example uses a deterministic in-memory data source so the SSR example works without external network access.',
42 },
43 {
44 id: 5,
45 title: 'Keep the setup small',
46 body: 'Only the Angular CLI SSR pieces remain: main.server.ts, server.ts and the server application config.',
47 },
48 {
49 id: 6,
50 title: 'Match the other examples',
51 body: 'The rest of the app keeps the same lightweight structure as the existing Angular examples in this repo.',
52 },
53]