Vue.js course · Module 9: Composables & VueUse
Project: Lab Manager with Composables
In this lesson4
A complete NOVA LAB laboratory management system using all the techniques you've learned! Dr. Nova needs a panel that fetches the list of experiments from the server, lets you search, filter and sort it, splits the results into pages and allows deleting entries. If you wrote all of that into one component, you would end up with several hundred lines in which data fetching gets mixed up with pagination. Instead we will build three composables, each with one job, and a component that connects them. Data flows along one path: useExperiments() fetches and stores the experiments, useLabFilters(experiments) filters them, usePagination(filtered) splits the result into pages, and the template displays paginatedItems.
The Data Layer: useExperiments
The first file, composables/useExperiments.js, is responsible for the data. It returns the state, the loading and error flags and the CRUD functions - short for Create, Read, Update, Delete. Derived values, such as the list of critical experiments and the number of categories, are calculated by computed:
// composables/useExperiments.js
import { ref, computed } from 'vue'
export function useExperiments() {
const experiments = ref([])
const loading = ref(false)
const error = ref(null)
const criticalExperiments = computed(() =>
experiments.value.filter(exp => exp.critical)
)
const categoriesCount = computed(() =>
new Set(experiments.value.map(exp => exp.category)).size
)
async function fetchExperiments() {
loading.value = true
error.value = null
try {
const response = await fetch('/api/mars/experiments')
if (!response.ok) throw new Error('Failed to fetch')
experiments.value = await response.json()
} catch (e) {
error.value = e.message
} finally {
loading.value = false
}
}
async function addExperiment(experiment) {
const response = await fetch('/api/mars/experiments', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(experiment)
})
const newExperiment = await response.json()
experiments.value.push(newExperiment)
}
async function deleteExperiment(id) {
await fetch(`/api/mars/experiments/${id}`, { method: 'DELETE' })
experiments.value = experiments.value.filter(exp => exp.id !== id)
}
return {
experiments,
loading,
error,
criticalExperiments,
categoriesCount,
fetchExperiments,
addExperiment,
deleteExperiment
}
}We have reading, creating and deleting; you will add updating as an extension. It's also worth adding two things from the previous lessons right away: a response.ok check in addExperiment and an AbortController that cancels the fetch on unmount.
Filtering: useLabFilters
The second composable takes a parameter - a ref with the list of experiments - and builds a filtered, sorted version from it. It knows nothing about the server, so it works with any list whose items have name and category fields:
// composables/useLabFilters.js
import { ref, computed } from 'vue'
export function useLabFilters(experiments) {
const searchQuery = ref('')
const selectedCategory = ref('')
const sortBy = ref('name')
const sortOrder = ref('asc')
const filteredExperiments = computed(() => {
let result = experiments.value
// Search
if (searchQuery.value) {
const query = searchQuery.value.toLowerCase()
result = result.filter(exp =>
exp.name.toLowerCase().includes(query) ||
exp.category.toLowerCase().includes(query)
)
}
// Filter by category
if (selectedCategory.value) {
result = result.filter(exp => exp.category === selectedCategory.value)
}
// Sort
result = [...result].sort((a, b) => {
const aVal = a[sortBy.value]
const bVal = b[sortBy.value]
const order = sortOrder.value === 'asc' ? 1 : -1
if (typeof aVal === 'string') {
return aVal.localeCompare(bVal) * order
}
return (aVal - bVal) * order
})
return result
})
const uniqueCategories = computed(() =>
[...new Set(experiments.value.map(exp => exp.category))].sort()
)
function resetFilters() {
searchQuery.value = ''
selectedCategory.value = ''
sortBy.value = 'name'
sortOrder.value = 'asc'
}
return {
searchQuery,
selectedCategory,
sortBy,
sortOrder,
filteredExperiments,
uniqueCategories,
resetFilters
}
}Note the [...result].sort: the sort method changes an array in place, so without the copy we would sort the original list from useExperiments. Strings are compared with localeCompare, and numbers, such as the year, with plain subtraction.
Pagination: usePagination
The third composable splits any list into pages. The number of pages is calculated by a computed with Math.ceil, and the current slice by slice:
// composables/usePagination.js
import { ref, computed } from 'vue'
export function usePagination(items, itemsPerPage = 12) {
const currentPage = ref(1)
const perPage = ref(itemsPerPage)
const totalPages = computed(() =>
Math.ceil(items.value.length / perPage.value)
)
const paginatedItems = computed(() => {
const start = (currentPage.value - 1) * perPage.value
const end = start + perPage.value
return items.value.slice(start, end)
})
function goToPage(page) {
if (page >= 1 && page <= totalPages.value) {
currentPage.value = page
}
}
function nextPage() {
goToPage(currentPage.value + 1)
}
function prevPage() {
goToPage(currentPage.value - 1)
}
return {
currentPage,
perPage,
totalPages,
paginatedItems,
goToPage,
nextPage,
prevPage
}
}goToPage ignores numbers outside the range. One trap: if you are on page 3 and narrow the filter to a single page of results, currentPage stays at 3 and the list shows up empty. The fix is one line in the composable, plus a watch import: watch(items, () => { currentPage.value = 1 }).
The LabManager Component
Time to connect the modules in the panel. The first part of the template is the header with counters and the filter panel, in which v-model binds the form fields to the refs from useLabFilters:
<!-- LabManager.vue -->
<template>
<div class="lab-manager">
<!-- Header -->
<header>
<h1>NOVA LAB - Experiment Management</h1>
<p>{{ categoriesCount }} categories, {{ experiments.length }} experiments</p>
</header>
<!-- Filters -->
<aside class="filters">
<input v-model="searchQuery" placeholder="Search experiments..." />
<select v-model="selectedCategory">
<option value="">All categories</option>
<option v-for="category in uniqueCategories" :key="category" :value="category">
{{ category }}
</option>
</select>
<select v-model="sortBy">
<option value="name">Name</option>
<option value="category">Category</option>
<option value="year">Year</option>
</select>
<button @click="sortOrder = sortOrder === 'asc' ? 'desc' : 'asc'">
{{ sortOrder === 'asc' ? '↑' : '↓' }}
</button>
<button @click="resetFilters">Reset</button>
</aside>Every change in the search field immediately recalculates filteredExperiments, and after it paginatedItems - without a single line of event-handling code. The second part shows the loading state, the grid of cards and the pagination. We skip the ExperimentCard component - it displays an experiment card and emits a delete event:
<!-- Loading/Error -->
<div v-if="loading">Loading experiments...</div>
<div v-else-if="error">Error: {{ error }}</div>
<!-- Lab Dashboard -->
<main v-else class="lab-grid">
<ExperimentCard
v-for="experiment in paginatedItems"
:key="experiment.id"
:experiment="experiment"
@delete="deleteExperiment(experiment.id)"
/>
</main>
<!-- Pagination -->
<footer class="pagination">
<button @click="prevPage" :disabled="currentPage === 1">
Previous
</button>
<button
v-for="page in totalPages"
:key="page"
@click="goToPage(page)"
:class="{ active: currentPage === page }"
>
{{ page }}
</button>
<button @click="nextPage" :disabled="currentPage === totalPages">
Next
</button>
</footer>
</div>
</template>v-for="page in totalPages" iterates over a number, so it yields 1, 2, 3 and so on up to totalPages. Finally the script, in which you import the composables, destructure the returned API and pass the result of one as the parameter of the next:
<script setup>
import { onMounted } from 'vue'
import { useExperiments } from './composables/useExperiments'
import { useLabFilters } from './composables/useLabFilters'
import { usePagination } from './composables/usePagination'
// Composables
const {
experiments,
loading,
error,
categoriesCount,
fetchExperiments,
deleteExperiment
} = useExperiments()
const {
searchQuery,
selectedCategory,
sortBy,
sortOrder,
filteredExperiments,
uniqueCategories,
resetFilters
} = useLabFilters(experiments)
const {
currentPage,
totalPages,
paginatedItems,
goToPage,
nextPage,
prevPage
} = usePagination(filteredExperiments, 12)
// Lifecycle
onMounted(() => {
fetchExperiments()
})
</script>The order of the calls mirrors the data flow: experiments goes into the filters, filteredExperiments into the pagination, and we fetch the data in onMounted. The component contains no business logic - it only glues it together.
My advice: stick to the rule of one job per composable. Thanks to it you can use usePagination in any other list on the station, and test each composable separately, as in the lesson on testing. In the editor below you will find a related example of module integration: useTimer, useModuleStatus and useNotifications come together in one panel following the same rule.
Remember: the Lab Manager is a station built from modules - each composable does one thing, and the component only connects them.
Code for this lesson: App.vue
<script setup>
import { ref, computed, watch, onMounted } from 'vue'
// Best Practice 1: Single Responsibility
function useTimer(initialSeconds = 0) {
const seconds = ref(initialSeconds)
const isRunning = ref(false)
let intervalId = null
const formattedTime = computed(() => {
const mins = Math.floor(seconds.value / 60)
const secs = seconds.value % 60
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`
})
function start() {
if (isRunning.value) return
isRunning.value = true
intervalId = setInterval(() => {
seconds.value++
}, 1000)
}
function pause() {
isRunning.value = false
if (intervalId) {
clearInterval(intervalId)
intervalId = null
}
}
function reset() {
pause()
seconds.value = initialSeconds
}
return {
seconds,
formattedTime,
isRunning,
start,
pause,
reset
}
}
// Best Practice 2: Composable Composition
function useModuleStatus(moduleName) {
const isOnline = ref(true)
const temperature = ref(22)
const powerConsumption = ref(45)
const status = computed(() => {
if (!isOnline.value) return { level: 'offline', color: '#666666' }
if (temperature.value > 80) return { level: 'critical', color: '#ff0055' }
if (powerConsumption.value > 80) return { level: 'warning', color: '#ffb400' }
return { level: 'optimal', color: '#00ff88' }
})
// Use timer composable
const uptime = useTimer()
// Auto-start uptime timer when online
watch(isOnline, (newValue) => {
if (newValue) {
uptime.start()
} else {
uptime.pause()
}
}, { immediate: true })
function toggleOnline() {
isOnline.value = !isOnline.value
}
function adjustTemperature(delta) {
temperature.value = Math.max(0, Math.min(100, temperature.value + delta))
}
function adjustPower(delta) {
powerConsumption.value = Math.max(0, Math.min(100, powerConsumption.value + delta))
}
return {
moduleName: ref(moduleName),
isOnline,
temperature,
powerConsumption,
status,
uptime,
toggleOnline,
adjustTemperature,
adjustPower
}
}
// Best Practice 3: Options with defaults
function useNotifications(options = {}) {
const {
maxNotifications = 10,
autoRemove = true,
autoRemoveDelay = 5000
} = options
const notifications = ref([])
let notificationId = 0
function add(message, type = 'info') {
notificationId++
const notification = {
id: notificationId,
message,
type,
timestamp: new Date()
}
notifications.value.unshift(notification)
if (notifications.value.length > maxNotifications) {
notifications.value.pop()
}
if (autoRemove) {
setTimeout(() => {
remove(notification.id)
}, autoRemoveDelay)
}
return notification
}
function remove(id) {
const index = notifications.value.findIndex(n => n.id === id)
if (index !== -1) {
notifications.value.splice(index, 1)
}
}
function clear() {
notifications.value = []
}
return {
notifications,
add,
remove,
clear
}
}
// Initialize modules
const habitatModule = useModuleStatus('Habitat Module')
const researchModule = useModuleStatus('Research Module')
const powerModule = useModuleStatus('Power Module')
// Initialize notifications
const notify = useNotifications({
maxNotifications: 5,
autoRemove: true,
autoRemoveDelay: 4000
})
// Module simulation
function simulateHeatWave(module) {
module.adjustTemperature(30)
notify.add(`Heat wave detected in ${module.moduleName.value}`, 'warning')
}
function simulateCooling(module) {
module.adjustTemperature(-20)
notify.add(`Cooling system activated in ${module.moduleName.value}`, 'info')
}
function simulatePowerSpike(module) {
module.adjustPower(40)
notify.add(`Power spike in ${module.moduleName.value}`, 'warning')
}
onMounted(() => {
notify.add('NOVA LAB Module Integration System Online', 'success')
})
</script>
<template>
<div class="integration-lab">
<div class="header">
<h1>Module Integration - NOVA LAB</h1>
<p class="subtitle">Module 6: Best Practices & Composable Patterns</p>
</div>
<!-- Notifications Panel -->
<div class="notifications-panel">
<div class="notifications-header">
<h3>System Notifications</h3>
<button @click="notify.clear()" class="btn btn-sm btn-danger">Clear All</button>
</div>
<div class="notifications-list">
<div
v-for="notification in notify.notifications.value"
:key="notification.id"
class="notification"
:class="'notification-' + notification.type"
>
<span class="notification-type">{{ notification.type.toUpperCase() }}</span>
<span class="notification-message">{{ notification.message }}</span>
<button @click="notify.remove(notification.id)" class="btn-close">×</button>
</div>
</div>
</div>
<!-- Modules Grid -->
<div class="modules-grid">
<!-- Habitat Module -->
<div class="module-card" :style="{ borderColor: habitatModule.status.value.color }">
<div class="module-header">
<h3>{{ habitatModule.moduleName.value }}</h3>
<div
class="status-badge"
:style="{ background: habitatModule.status.value.color }"
>
{{ habitatModule.status.value.level.toUpperCase() }}
</div>
</div>
<div class="module-stats">
<div class="stat">
<span class="stat-label">Temperature:</span>
<span class="stat-value">{{ habitatModule.temperature.value }}°C</span>
</div>
<div class="stat">
<span class="stat-label">Power:</span>
<span class="stat-value">{{ habitatModule.powerConsumption.value }}%</span>
</div>
<div class="stat">
<span class="stat-label">Uptime:</span>
<span class="stat-value">{{ habitatModule.uptime.formattedTime.value }}</span>
</div>
</div>
<div class="module-controls">
<button
@click="habitatModule.toggleOnline()"
class="btn"
:class="habitatModule.isOnline.value ? 'btn-warning' : 'btn-success'"
>
{{ habitatModule.isOnline.value ? 'Shutdown' : 'Power On' }}
</button>
</div>
<div class="module-simulations">
<button @click="simulateHeatWave(habitatModule)" class="btn btn-sm">Heat Wave</button>
<button @click="simulateCooling(habitatModule)" class="btn btn-sm">Cooling</button>
<button @click="simulatePowerSpike(habitatModule)" class="btn btn-sm">Power Spike</button>
</div>
</div>
<!-- Research Module -->
<div class="module-card" :style="{ borderColor: researchModule.status.value.color }">
<div class="module-header">
<h3>{{ researchModule.moduleName.value }}</h3>
<div
class="status-badge"
:style="{ background: researchModule.status.value.color }"
>
{{ researchModule.status.value.level.toUpperCase() }}
</div>
</div>
<div class="module-stats">
<div class="stat">
<span class="stat-label">Temperature:</span>
<span class="stat-value">{{ researchModule.temperature.value }}°C</span>
</div>
<div class="stat">
<span class="stat-label">Power:</span>
<span class="stat-value">{{ researchModule.powerConsumption.value }}%</span>
</div>
<div class="stat">
<span class="stat-label">Uptime:</span>
<span class="stat-value">{{ researchModule.uptime.formattedTime.value }}</span>
</div>
</div>
<div class="module-controls">
<button
@click="researchModule.toggleOnline()"
class="btn"
:class="researchModule.isOnline.value ? 'btn-warning' : 'btn-success'"
>
{{ researchModule.isOnline.value ? 'Shutdown' : 'Power On' }}
</button>
</div>
<div class="module-simulations">
<button @click="simulateHeatWave(researchModule)" class="btn btn-sm">Heat Wave</button>
<button @click="simulateCooling(researchModule)" class="btn btn-sm">Cooling</button>
<button @click="simulatePowerSpike(researchModule)" class="btn btn-sm">Power Spike</button>
</div>
</div>
<!-- Power Module -->
<div class="module-card" :style="{ borderColor: powerModule.status.value.color }">
<div class="module-header">
<h3>{{ powerModule.moduleName.value }}</h3>
<div
class="status-badge"
:style="{ background: powerModule.status.value.color }"
>
{{ powerModule.status.value.level.toUpperCase() }}
</div>
</div>
<div class="module-stats">
<div class="stat">
<span class="stat-label">Temperature:</span>
<span class="stat-value">{{ powerModule.temperature.value }}°C</span>
</div>
<div class="stat">
<span class="stat-label">Power:</span>
<span class="stat-value">{{ powerModule.powerConsumption.value }}%</span>
</div>
<div class="stat">
<span class="stat-label">Uptime:</span>
<span class="stat-value">{{ powerModule.uptime.formattedTime.value }}</span>
</div>
</div>
<div class="module-controls">
<button
@click="powerModule.toggleOnline()"
class="btn"
:class="powerModule.isOnline.value ? 'btn-warning' : 'btn-success'"
>
{{ powerModule.isOnline.value ? 'Shutdown' : 'Power On' }}
</button>
</div>
<div class="module-simulations">
<button @click="simulateHeatWave(powerModule)" class="btn btn-sm">Heat Wave</button>
<button @click="simulateCooling(powerModule)" class="btn btn-sm">Cooling</button>
<button @click="simulatePowerSpike(powerModule)" class="btn btn-sm">Power Spike</button>
</div>
</div>
</div>
<div class="info-panel">
<h3>Best Practices for Composables</h3>
<div class="info-grid">
<div class="info-section">
<h4>1. Single Responsibility</h4>
<ul>
<li>Each composable has a single responsibility</li>
<li>useTimer - only timer management</li>
<li>Easy to test and maintain</li>
</ul>
</div>
<div class="info-section">
<h4>2. Composable Composition</h4>
<ul>
<li>Combining composables for complex logic</li>
<li>useModuleStatus uses useTimer</li>
<li>Reusability and modularity</li>
</ul>
</div>
<div class="info-section">
<h4>3. Options Pattern</h4>
<ul>
<li>Accepting options with defaults</li>
<li>useNotifications({ maxNotifications: 5 })</li>
<li>Flexibility and customization</li>
</ul>
</div>
<div class="info-section">
<h4>4. Naming Convention</h4>
<ul>
<li>Always prefix with "use"</li>
<li>Descriptive name: useModuleStatus</li>
<li>Easy to identify</li>
</ul>
</div>
</div>
<div class="code-example">
<code>
// Good: Single responsibility
function useTimer() { ... }
// Good: Composition
function useModule() {
const timer = useTimer()
return { timer, ... }
}
// Good: Options with defaults
function useNotify(options = {}) {
const { maxItems = 10 } = options
...
}
</code>
</div>
</div>
</div>
</template>
<style scoped>
.integration-lab {
background: linear-gradient(135deg, #0a0e27 0%, #1a1e3f 100%);
min-height: 100vh;
padding: 2rem;
color: #ffffff;
font-family: 'Courier New', monospace;
}
.header {
text-align: center;
margin-bottom: 2rem;
padding-bottom: 1rem;
border-bottom: 2px solid #00ff88;
}
.header h1 {
font-size: 2.5rem;
color: #00ff88;
text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
margin: 0;
}
.subtitle {
color: #00b4d8;
font-size: 1.2rem;
margin-top: 0.5rem;
}
.notifications-panel {
background: rgba(0, 180, 216, 0.05);
border: 2px solid #00b4d8;
border-radius: 10px;
padding: 1.5rem;
margin-bottom: 2rem;
}
.notifications-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
}
.notifications-header h3 {
color: #00b4d8;
margin: 0;
}
.notifications-list {
display: flex;
flex-direction: column;
gap: 0.5rem;
max-height: 300px;
overflow-y: auto;
}
.notification {
display: flex;
align-items: center;
gap: 1rem;
padding: 1rem;
border-radius: 5px;
border-left: 4px solid;
animation: slideIn 0.3s ease;
}
@keyframes slideIn {
from {
transform: translateX(-20px);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
.notification-success {
background: rgba(0, 255, 136, 0.1);
border-color: #00ff88;
}
.notification-info {
background: rgba(0, 180, 216, 0.1);
border-color: #00b4d8;
}
.notification-warning {
background: rgba(255, 180, 0, 0.1);
border-color: #ffb400;
}
.notification-type {
color: #00b4d8;
font-size: 0.8rem;
font-weight: bold;
min-width: 80px;
}
.notification-message {
flex: 1;
color: #ffffff;
}
.btn-close {
background: rgba(255, 0, 85, 0.3);
color: #ff0055;
border: none;
width: 30px;
height: 30px;
border-radius: 50%;
font-size: 1.5rem;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
.btn-close:hover {
background: #ff0055;
color: #ffffff;
}
.modules-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 2rem;
margin-bottom: 2rem;
}
.module-card {
background: rgba(0, 255, 136, 0.05);
border: 3px solid;
border-radius: 10px;
padding: 1.5rem;
transition: all 0.3s ease;
}
.module-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
.module-header h3 {
color: #00ff88;
margin: 0;
}
.status-badge {
padding: 0.5rem 1rem;
border-radius: 20px;
font-size: 0.8rem;
font-weight: bold;
color: #0a0e27;
}
.module-stats {
background: rgba(0, 0, 0, 0.3);
border-radius: 8px;
padding: 1rem;
margin-bottom: 1rem;
}
.stat {
display: flex;
justify-content: space-between;
padding: 0.5rem 0;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.stat:last-child {
border-bottom: none;
}
.stat-label {
color: #00b4d8;
}
.stat-value {
color: #00ff88;
font-weight: bold;
}
.module-controls {
margin: 1rem 0;
}
.module-simulations {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
.btn {
padding: 0.75rem 1.5rem;
border: none;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
font-family: 'Courier New', monospace;
transition: all 0.3s ease;
width: 100%;
}
.btn-sm {
padding: 0.5rem 1rem;
font-size: 0.85rem;
width: auto;
flex: 1;
background: rgba(0, 180, 216, 0.3);
color: #00b4d8;
}
.btn-success {
background: #00ff88;
color: #0a0e27;
}
.btn-warning {
background: #ffb400;
color: #0a0e27;
}
.btn-danger {
background: #ff0055;
color: #ffffff;
}
.btn:hover {
transform: scale(1.05);
box-shadow: 0 5px 15px rgba(0, 255, 136, 0.3);
}
.info-panel {
background: rgba(0, 255, 136, 0.05);
border: 2px solid #00ff88;
border-radius: 10px;
padding: 2rem;
}
.info-panel h3 {
color: #00ff88;
margin-top: 0;
margin-bottom: 1.5rem;
text-align: center;
}
.info-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.info-section {
background: rgba(0, 180, 216, 0.1);
border: 2px solid #00b4d8;
border-radius: 8px;
padding: 1.5rem;
}
.info-section h4 {
color: #00b4d8;
margin-top: 0;
margin-bottom: 1rem;
}
.info-section ul {
list-style: none;
padding: 0;
margin: 0;
}
.info-section li {
padding: 0.5rem 0;
color: #ffffff;
font-size: 0.9rem;
line-height: 1.6;
}
.code-example {
background: rgba(0, 0, 0, 0.5);
border-left: 4px solid #00ff88;
border-radius: 5px;
padding: 1.5rem;
}
.code-example code {
color: #00ff88;
font-size: 0.9rem;
white-space: pre;
display: block;
}
</style>Docs entries used in this lesson
Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. What should the useExperiments composable return?
2. What do we use computed() for in composables?
These are 2 of 3 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Code editor
Build useExperiments with fetchExperiments, addExperiment, deleteExperiment, and computed properties.
- Vertical ordering
Arrange the composables workflow from creation to usage:
- Click in order
Arrange the pattern of a composable managing a data list:
- Horizontal ordering
Arrange a composable accepting a parameter:
- Code editor
Build useLabFilters with search, category, sort, and computed filteredItems.
- Vertical ordering
Arrange the steps for integrating multiple composables in a single component:
- Horizontal ordering
Arrange a computed property in a composable:
- Click in order
Arrange the full lifecycle of a composable in an application:
- Vertical ordering
Arrange the Lab Manager architecture from data to view:
- Click in order
Arrange script setup integrating composables:
- Horizontal ordering
Arrange the import path for a composable:
- Vertical ordering
Arrange the steps for initializing a composable that fetches data from a server:
Tasks after this lesson
- QuestionuseExperiments Composable
- QuestionComputed in Composables
- Coding taskPractice: useExperiments
- Put in orderComposables Workflow
- Click in orderCRUD Composable Pattern
- Put in orderComposable with a Parameter
- Coding taskPractice: useLabFilters
- QuestionComposable Composition
- Put in orderIntegrating Composables in a Component
- Put in orderComputed in a Composable
- Click in orderFull Composable Lifecycle
- Put in orderComposition in Lab Manager
- Click in orderscript setup with Composables
- Put in orderComposable File Location
- Put in orderProper Composable Initialization with API