Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo

createTimeline

A bounded undo/redo system that manages a fixed-size timeline of registered items with automatic overflow handling and history management.

Usage

The useTimeline composable extends useRegistry to provide undo/redo functionality with a bounded history. When the timeline reaches its size limit, older items are moved to an overflow buffer, allowing you to undo back to them while maintaining a fixed active timeline size.

ts
import { createTimeline } from '@vuetify/v0'

const timeline = createTimeline({ size: 10 })

// Register actions
timeline.register({ id: 'action-1', value: 'Created document' })
timeline.register({ id: 'action-2', value: 'Added title' })
timeline.register({ id: 'action-3', value: 'Added paragraph' })

console.log(timeline.size) // 3

// Undo the last action
timeline.undo()
console.log(timeline.size) // 2

// Redo the undone action
timeline.redo()
console.log(timeline.size) // 3

Architecture

useTimeline extends useRegistry with bounded history and overflow management:

Diagram

Click outside or press Escape to close

API Reference

The following API details are for the useTimeline composable.

Functions

createTimeline

(_options?: TimelineOptions) => E

Creates a new timeline instance.

createTimelineContext

(_options?: TimelineContextOptions) => ContextTrinity<E>

Creates a new timeline context.

useTimeline

(namespace?: string) => E

Returns the current timeline instance.

Options

events

boolean

Enable event emission for registry operations

Default: false

size

number

The maximum size of the timeline.

Default: 10

Properties

collection

ReadonlyMap<ID, Z>

The collection of tickets in the registry

size

number

The number of tickets in the registry

Methods

clear

() => void

Clear the entire registry

has

(id: ID) => boolean

Check if a ticket exists by ID

keys

() => ID[]

Get all registered IDs

browse

(value: unknown) => ID[] | undefined

Browse for an ID(s) by value

lookup

(index: number) => ID | undefined

lookup a ticket by index number

get

(id: ID) => Z | undefined

Get a ticket by ID

upsert

(id: ID, ticket?: Partial<Z>) => Z

Update or insert a ticket by ID

values

() => Z[]

Get all values of registered tickets

entries

() => [ID, Z][]

Get all entries of registered tickets

register

(ticket?: Partial<Z>) => Z

Register a new ticket

unregister

(id: ID) => void

Unregister an ticket by ID

reindex

() => void

Reset the index directory and update all tickets

seek

(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => Z | undefined

Seek for a ticket based on direction and optional predicate

on

(event: string, cb: RegistryEventCallback) => void

Listen for registry events

off

(event: string, cb: RegistryEventCallback) => void

Stop listening for registry events

emit

(event: string, data: unknown) => void

Emit an event with data

dispose

() => void

Clears the registry and removes all listeners

onboard

(registrations: Partial<Z>[]) => Z[]

Onboard multiple tickets at once

offboard

(ids: ID[]) => void

Offboard multiple tickets at once

batch

<R>(fn: () => R) => R

Execute operations in a batch, deferring cache invalidation and event emission until complete

undo

() => Z | undefined

Removes the last registered ticket and stores it for redo

redo

() => Z | undefined

Restores the last undone ticket


© 2016-2026 Vuetify, LLC
Ctrl+/