SolidJS
이 콘텐츠는 아직 번역되지 않았습니다.
import { createSignal } from "solid-js";import { shallowEqual } from "@lumen-timeline/core";import { createEditorSelector, createTimeline, TimelineContext } from "@lumen-timeline/solid";import "@lumen-timeline/timeline/style.css";
export function Workspace(props) { const [element, setElement] = createSignal(); const [snap] = createSignal({ gridTicks: 28224000 }); const view = createTimeline(element, () => ({ editor: props.editor, transport: props.transport, snap: snap(), })); const clip = createEditorSelector( () => props.editor, ({ snapshot, selection }) => { const found = snapshot.clips.find((c) => c.id === selection.at(-1)); return found ? { name: found.name, take: found.activeTakeId } : null; }, shallowEqual, ); return ( <TimelineContext value={{ editor: props.editor, transport: props.transport }}> <div ref={setElement} /> <aside>{clip() ? `${clip().name}: ${clip().take}` : "No clip selected"}</aside> </TimelineContext> );}createTimeline(element, options)mounts the view inelementonce the render has settled, and disposes it with its owner. Give the element as a signal, with its setter as theref, and the options as an accessor. It returns an accessor of the view,undefineduntil it mounts.createEditorSelector(editor, select, isEqual)returns an accessor of the field. It subscribes from its first effect run until its owner is disposed.editormay be an accessor, which a host that switches editors passes.createTransportSelector(transport, select, isEqual)does the same for a transport’s snapshot.<TimelineContext value={{ editor, transport }}>anduseTimelineContext()hand the host’s editor and transport down. A host that switches them passes an object whose properties are getters of its signals.useTimelineContextthrows without a provider.- SolidJS 2’s JSX compiler was published only under
nexttags when this was tested. The package has no JSX and does not depend on it; an application compiles its own.