|
| 1 | +# Scully Core |
| 2 | + |
| 3 | +## Idle Monitor |
| 4 | + |
| 5 | +Scully implements the `IdleMonitorService` to hook into Zonejs. When angular goes idle (**more precise, when all outgoing HTTP-requests are settled**) |
| 6 | +Scully trigger Puppeteer, and knows when it's ready to render. |
| 7 | + |
| 8 | +Without this process, we have to resort to a (25 seconds) timeout. this is both slower and unprecise, some pages need even more time. |
| 9 | + |
| 10 | +`IdleMonitorService` is available in `ScullyLibModule`. |
| 11 | + |
| 12 | +## Router Service |
| 13 | + |
| 14 | +`ScullyRoutesService` is an service to provide to the user access to certains methods and observables to know |
| 15 | +the routes rendered by Scully. |
| 16 | + |
| 17 | +- available\$ |
| 18 | +- unPublished\$ |
| 19 | +- topLevel\$ |
| 20 | +- getCurrent() |
| 21 | +- reload() |
| 22 | + |
| 23 | +The `ScullyRoutesService` use the `ScullyRoute` interface to set types. |
| 24 | + |
| 25 | +```typescript |
| 26 | +export interface ScullyRoute { |
| 27 | + route: string; |
| 28 | + title?: string; |
| 29 | + slugs?: string[]; |
| 30 | + published?: boolean; |
| 31 | + slug?: string; |
| 32 | + [prop: string]: any; |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +#### available\$: _Observable<ScullyRoute[]>_ |
| 37 | + |
| 38 | +`available$` returns routes with the property `published` with value true. |
| 39 | + |
| 40 | +#### unPublished\$: _Observable<ScullyRoute[]>_ |
| 41 | + |
| 42 | +`unPublished$` returns routes with the property `published` with value false. |
| 43 | + |
| 44 | +#### topLevel\$: _Observable<ScullyRoute[]>_ |
| 45 | + |
| 46 | +`topLevel$` returns top level routes. |
| 47 | + |
| 48 | +#### getCurrent(): _Observable<ScullyRoute>_ |
| 49 | + |
| 50 | +`getCurrent()` method returns the current location |
| 51 | + |
| 52 | +#### reload(): _void_ |
| 53 | + |
| 54 | +`reload` method checks if new routes was added in the `scully-routes.json`. |
| 55 | + |
| 56 | +## Scully Content |
| 57 | + |
| 58 | +Scully use the `scully-content` to insert the result of the render process into the HTML document. |
| 59 | + |
| 60 | +The `scully-content` component won't work inside a `*ngIf` directive. |
| 61 | + |
| 62 | +## Transfer State |
| 63 | + |
| 64 | +The `TransferStateService` allows transfer the state of the Angular application to the static site rendered by Scully. |
| 65 | + |
| 66 | +To set or get the state of the application you can use 2 methods: |
| 67 | + |
| 68 | +- getState |
| 69 | +- setState |
| 70 | + |
| 71 | +#### getState |
| 72 | + |
| 73 | +`getState` will return an observable that fires once and completes. It does so right after the navigation for the page has finished. |
| 74 | + |
| 75 | +```typescript |
| 76 | +getState<T>(name: string): Observable<T> |
| 77 | +``` |
| 78 | + |
| 79 | +#### setState |
| 80 | + |
| 81 | +`setState` will set values to the property key. |
| 82 | + |
| 83 | +```typescript |
| 84 | +setState<T>(name: string, val: T): void |
| 85 | +``` |
| 86 | + |
| 87 | +## Utils |
| 88 | + |
| 89 | +#### Is Scully |
| 90 | + |
| 91 | +- isScullyRunning() |
| 92 | +- isScullyGenerated() |
| 93 | + |
| 94 | +##### isScullyRunning(): _boolean_ |
| 95 | + |
| 96 | +`isScullyRunning` returns `true` or `false` if Scully build is happening. |
| 97 | + |
| 98 | +##### isScullyGenerated(): _boolean_ |
| 99 | + |
| 100 | +`isScullyGenerated` returns `true` if Scully build has run. |
| 101 | + |
| 102 | +[Full Documentation ➡️](scully.md) |
0 commit comments