concept onMount in category svelte
appears as: onMount

This is an excerpt from Manning's book Svelte and Sapper in Action.
<script context="module"> export function add(n1, n2) { return n1 + n2; } </script> <script> <!-- Component JavaScript goes here. --> </script> <!-- Component HTML goes here. --> <style> /* Component CSS goes here. */ </style>
<script> import Demo from './Demo.svelte'; let show = false; #1 </script> <label> <input type="checkbox" bind:checked={show}> Show </label> {#if show} <Demo /> {/if}
Here is an example that retrieves data about employees at a company from an API service when the component is mounted. This is the same API service described in section 4.3. The array of employee objects returned is sorted by their names (first name before last name) and stored in a top-level variable. The component renders the employee data in a table (see figure 8.1).